Empty IN Clause when viewing blogs
Submitted
AndyMillne
, Apr 12 2012 01:36 PM | Last updated Apr 12 2012 01:36 PM
blogFunctions::rebuildMyBlogsCache()
if all of the returned blogs are disabled we can end up with an empty IN clause.
we need to check for a populated array here.
if all of the returned blogs are disabled we can end up with an empty IN clause.
$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') );we need to check for a populated array here.
| Status: | Fixed |
| Version: | 2.5.2 |
| Fixed In: | 2.5.2 |











1 Comments
Open the file "\admin\applications_addon\ips\blog\sources\classes\blogFunctions.php" and find (lines 1198-1208):
/* Get entries and comments */ $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']; } }replace with:
/* Get entries and comments */ if ( count($blogs) ) { $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']; } } }