Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-12-2017, 10:58 AM
CarolSEL CarolSEL is offline
 
Join Date: Aug 2010
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL error?

We're getting continuing error notifications when the site owner and other members attempt to log in. New registrants often cannot log in. The message is:

Database error in vBulletin 4.2.4:

Invalid SQL:
SELECT COUNT(*) AS num
FROM vb3_moderation AS moderation
INNER JOIN vb3_post AS post ON (moderation.primaryid = post.postid)
INNER JOIN vb3_thread AS thread ON (post.threadid = thread.threadid)
WHERE type = 'reply' AND forumid IN ( );
MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 5
Error Number : 1064

--------------------------------------

MySQL version 5.6.35
PHP version 5.5.38
Server Type: Linux
Web Server: Apachi (cgi-fcgi)

Host tells us it's from "poor coding" in the FractalizeR notifications plugin. When we turn that off, Mods don't get notifications. There aren't any coders among us, so I have 2 questions:

1) What is the syntax error that is producing the empty parentheses?
2) In which file will we find it?

Thanks for any help!!
Reply With Quote
  #2  
Old 08-12-2017, 01:45 PM
bridge2heyday's Avatar
bridge2heyday bridge2heyday is offline
 
Join Date: Aug 2014
Location: Egypt
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin MySQL error messages give info about referrer .. this will be useful in your case .
Reply With Quote
  #3  
Old 08-12-2017, 06:50 PM
CarolSEL CarolSEL is offline
 
Join Date: Aug 2010
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Script : http://www.catholicforum.com/forums/login.php?do=login
Referrer : http://www.catholicforum.com/forums/content.php

Site owner emailed me saying he got this message after turning off all plugins except notifications:
PHP Warning: implode(): Invalid arguments passed in ..../includes/class_bootstrap.php(1230) : eval()'d code on line 40

PHP Warning: mysqli_query(): (42000/1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 5 in ..../includes/class_core.php on line 1394
(By the way, he can log in from the ACP, but not the forum home page. Regular members obviously cannot do that.)
Reply With Quote
  #4  
Old 08-13-2017, 03:01 PM
bridge2heyday's Avatar
bridge2heyday bridge2heyday is offline
 
Join Date: Aug 2014
Location: Egypt
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This error resulting from code on hook location notifications_list .. looking at the mentioned product I don't find anything that can produce this error .. I guess you have a modified version of this addon .. Can you post the code on this hook location here ?
Reply With Quote
  #5  
Old 08-14-2017, 12:50 PM
CarolSEL CarolSEL is offline
 
Join Date: Aug 2010
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hopefully this is what you're asking for (Showing Notifications):

function modForums($vbulletin) {
$userid = $vbulletin->userinfo['userid'];
$ismod_all = "SELECT childlist AS fid FROM ". TABLE_PREFIX ."forum
WHERE forumid IN ( SELECT forumid
FROM ". TABLE_PREFIX ."moderator
WHERE userid = ". $userid ." AND forumid != -1 )";
$fr_result = $vbulletin->db->query_read_slave($ismod_all);
while($fr_entry = $vbulletin->db->fetch_array($fr_result)) {
$fr_forums[] = $fr_entry['fid'];
}
return $fr_forums;
}

function isSuperMod ($vbulletin) {
if($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']) {
return true;
} else {
return false;
}
}

$fr_UserGroupsAllowed = explode(',', $vbulletin->options ['fr_items_to_moderate_showtogroups']);
$groupids = explode(',', $vbulletin->userinfo ['usergroupid'].','. $vbulletin->userinfo['membergroupids']);
if(array_intersect($fr_UserGroupsAllowed, $groupids)){

$m_forums = "";
if(!isSuperMod($vbulletin)){
$m_forums = "AND forumid IN ( ". implode(',', modForums( $vbulletin)) ." )";
}
$fr_itemsToTrack = explode(',', $vbulletin->options ['fr_itemstotrack']);

//All moderation items
$fr_modItems = array (
'thread' => array(
'link' => $vbulletin->options['bburl'] . '/moderation.php?do=viewthreads&type=moderated',
'total' => 0
),
'reply' => array(
'link' => $vbulletin->options['bburl'] . '/moderation.php?do=viewposts&type=moderated',
'total' => 0
),
'visitormessage' => array(
'link' => $vbulletin->options['bburl'] . '/' . trim($vbulletin->config['Misc']['modcpdir'], '/') . '/moderate.php?do=messages',
'total' => 0
),
'groupmessage' => array(
'link' => $vbulletin->options['bburl'] . '/moderation.php?do=viewgms&type=moderated',
'total' => 0
),
'picturecomment' => array(
'link' => $vbulletin->options['bburl'] . '/moderation.php?do=viewpcs&type=moderated',
'total' => 0
),
'event' => array(
'link' => $vbulletin->options['bburl'] . '/' . trim($vbulletin->config['Misc']['modcpdir'], '/') . '/moderate.php?do=events',
'total' => 0
),
'user' => array(
'link' => $vbulletin->options['bburl'] . '/' . trim($vbulletin->config['Misc']['admincpdir'], '/') . '/user.php?do=moderate',
'total' => 0
),
'attachments' => array(
'link' => $vbulletin->options['bburl'] . '/' . trim($vbulletin->config['Misc']['modcpdir'], '/') . '/moderate.php?do=attachments',
'total' => 0
),
'picture' => array(
'link' => $vbulletin->options['bburl'] . '/moderation.php?do=viewpics',
'total' => 0
)
);

//#################### Acquiring ####################
//reply - post
if(in_array('reply', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM " . TABLE_PREFIX . "moderation AS moderation
INNER JOIN " . TABLE_PREFIX . "post AS post ON (moderation.primaryid = post.postid)
INNER JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
WHERE type = 'reply' ". $m_forums;
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['reply'] ['total'] = $fr_result['num'];
}

//thread
if(in_array('thread', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM " . TABLE_PREFIX . "moderation AS moderation
INNER JOIN " . TABLE_PREFIX . "thread AS thread ON (moderation.primaryid = thread.threadid)
WHERE type = 'thread' ". $m_forums;
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['thread'] ['total'] = $fr_result['num'];
}

//visitormessage, groupmessage, picturecomment
if(count(array_intersect($fr_itemsToTrack, array('visitormessage', 'groupmessage', 'picturecomment')))>0) {
$query = "SELECT COUNT(type) AS total, type
FROM ". TABLE_PREFIX ."moderation
GROUP BY type";
$fr_result = $vbulletin->db->query_read($query);
while($fr_entry = $vbulletin->db->fetch_array($fr_result)) {
$fr_modItems[$fr_entry['type']] ['total'] = $fr_entry['total'];
}
}

//event
if(in_array('event', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM ". TABLE_PREFIX ."event
WHERE visible=0";
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['event'] ['total'] = $fr_result['num'];
}

//user
if(in_array('user', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM ". TABLE_PREFIX ."user
WHERE usergroupid = 4";
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['user'] ['total'] = $fr_result['num'];
}

//picture
if(in_array('picture', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM ". TABLE_PREFIX ."picturecomment
WHERE state='moderation'";
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['picture'] ['total'] = $fr_result['num'];
}

//attachments
if(in_array('attachments', $fr_itemsToTrack)) {
$query = "SELECT COUNT(*) AS num
FROM ". TABLE_PREFIX ."attachment
WHERE state='moderation'";
$fr_result = $vbulletin->db->query_first($query);
$fr_modItems['attachments'] ['total'] = $fr_result['num'];
}

//#################### Placing into notifications area ####################
foreach($fr_modItems as $fr_modItemType => $fr_modItemValue) {
//Checking if we track item
if(!in_array($fr_modItemType, $fr_itemsToTrack)) {
continue;
}

//Checking zero values
//if(($fr_modItemValue['total'] == 0) and (!$vbulletin->options['fr_displayifzero'])) {
if($fr_modItemValue['total'] == 0) {
continue;
}

//Adding to notifications
$vbulletin->userinfo ['fr_items_to_moderate_' . $fr_modItemType] = $fr_modItemValue ['total'];
$notifications ['fr_items_to_moderate_' . $fr_modItemType] = array (
'phrase' => $vbphrase ['fr_items_to_moderate_' . $fr_modItemType],
'total' => $fr_modItemValue ['total'],
'link' => $fr_modItemValue ['link'] . $vbulletin->session->vars ['sessionurl_q'],
'order' => 10);
}
}
Reply With Quote
  #6  
Old 08-14-2017, 02:01 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is here:
PHP Code:
if(!isSuperMod($vbulletin)){
$m_forums "AND forumid IN ( "implode(','modForums$vbulletin)) ." )";

the modForums function returns no records, therefore the IN clause will fail. Adding a count check after the isSuperMod check should fix this problem.
Reply With Quote
  #7  
Old 08-14-2017, 03:19 PM
CarolSEL CarolSEL is offline
 
Join Date: Aug 2010
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
The problem is here:
PHP Code:
if(!isSuperMod($vbulletin)){
$m_forums "AND forumid IN ( "implode(','modForums$vbulletin)) ." )";

the modForums function returns no records, therefore the IN clause will fail. Adding a count check after the isSuperMod check should fix this problem.
Thanks, Dave, but a question: How do I add a count check??
Reply With Quote
  #8  
Old 08-14-2017, 04:13 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can try changing it to
PHP Code:
if(!isSuperMod($vbulletin) && count(modForums($vbulletin)) > 0){
$m_forums "AND forumid IN ( "implode(','modForums$vbulletin)) ." )";

Reply With Quote
2 благодарности(ей) от:
bridge2heyday, RichieBoy67
  #9  
Old 08-14-2017, 06:16 PM
CarolSEL CarolSEL is offline
 
Join Date: Aug 2010
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A million thanks, Dave! It worked for our site owner. Now we'll see if it helps the regular members log in, too!
Reply With Quote
  #10  
Old 08-14-2017, 07:40 PM
Stingray27 Stingray27 is offline
 
Join Date: Jan 2006
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
You can try changing it to
PHP Code:
if(!isSuperMod($vbulletin) && count(modForums($vbulletin)) > 0){
$m_forums "AND forumid IN ( "implode(','modForums$vbulletin)) ." )";

A simpler and more common trick is simply to add a zero at the start of the IN() ;

PHP Code:
if(!isSuperMod($vbulletin)){
$m_forums "AND forumid IN ( 0"implode(','modForums$vbulletin)) ." )";

Reply With Quote
Благодарность от:
RichieBoy67
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04784 seconds
  • Memory Usage 2,291KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (3)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete