Jump to content


Photo

Driver error in admincp caused by IP.Blog


when searching for a member recently who has no blogs in the ACP, I got a driver error.  Looking at the logfile in the cache directory, I found the following entry:

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Date: Wed, 16 May 2012 17:59:04 +0000
Error: 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 ') GROUP BY blog_id' at line 1
IP Address: 196.210.183.190 - /forums/admin/index.php?adsess=4f97d3a9f13faf2821512677cf1c0dc7&app=members&&module=members&section=members&do=viewmember&member_id=81723
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mySQL query error: SELECT blog_id, count(*) as entries, SUM(entry_num_comments) as comments FROM ibf_blog_entries WHERE blog_id IN () GROUP BY blog_id
.--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
| File    | Function   | Line No.   |
|----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------|
| admin/applications_addon/ips/blog/sources/classes/blogFunctions.php     | [blogFunctions].rebuildMyBlogsCache    | 1071   |
'----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'
| admin/applications_addon/ips/blog/extensions/admin/member_form.php | [blogFunctions].fetchMyBlogs   | 86     |
'----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'
| admin/applications/members/modules_admin/members/members.php    | [admin_member_form__blog].getDisplayContent    | 414    |
'----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'
| admin/applications/members/modules_admin/members/members.php    | [admin_members_members_members]._memberView    | 134    |
'----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'
| admin/sources/base/ipsController.php    | [admin_members_members_members].doExecute | 306    |
'----------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------'


I tracked this down to a coding issue in admin/applications_addon/ips/blog/sources/classes/blogFunctions.php at around line 1199 just after the comment /* Get entries and comments */.  The fix is to change this code:

$this->DB->build( array('select' => 'blog_id, count(*) as entries, SUM(entry_num_comments) as comments', 'from' => 'blog_entries', 'where' => 'blog_id IN (' . implode( ',', array_keys( $blogs ) ) . ')', 'group' => 'blog_id') );
    $this->DB->execute();
    while( $row = $this->DB->fetch() )
    {
	 if ( isset($blogs[ $row['blog_id'] ]) )
	 {
	  $blogs[ $row['blog_id'] ]['num_entries']	   = $row['entries'];
	  $blogs[ $row['blog_id'] ]['blog_num_comments'] = $row['comments'];
	 }
    }

to this:

if (count($blogs) > 0)
   {
    $this->DB->build( array('select' => 'blog_id, count(*) as entries, SUM(entry_num_comments) as comments', 'from' => 'blog_entries', 'where' => 'blog_id IN (' . implode( ',', array_keys( $blogs ) ) . ')', 'group' => 'blog_id') );
    $this->DB->execute();
    while( $row = $this->DB->fetch() )
    {
	 if ( isset($blogs[ $row['blog_id'] ]) )
	 {
	  $blogs[ $row['blog_id'] ]['num_entries']	   = $row['entries'];
	  $blogs[ $row['blog_id'] ]['blog_num_comments'] = $row['comments'];
	 }
    }
   }

Status: Duplicate
Version: 2.5.2
Fixed In:


1 Comments