Page 1 of 1

bug in counting entries

Posted: Fri Feb 16, 2007 5:33 pm
by igor
functions_entries.inc.php
$entries =& serendipity_db_query("SELECT count(id) ...
$entry_count will be 1 in all cases.

fix:
$entries =& serendipity_db_query("SELECT count(id) AS cnt ...
if (is_array($entries)) {
// this returns 1 in all cases! $entry_count = count($entries);
$entry_count = $entries['cnt'];
} else {
$entry_count = 0;
}

Re: bug in counting entries

Posted: Tue Feb 20, 2007 11:55 am
by garvinhicking
Hi!

It fetches the numerical index, so it should work (and at least it does in all installations I have acccess to).

Which database type and version are you using?

Best regards,
Garvin

Re: Re: bug in counting entries

Posted: Tue Feb 20, 2007 12:43 pm
by igor
Hi Garvin,

I use MySQL 5.0.27 with php 5.2.
without the fix i get 1 for the count of entries for every month in the list of 'older entries' (Archives).

File:
$Id: functions_entries.inc.php 1520 2006-11-30 21:34:29Z garvinhicking $

I found the problem in row 1471:
function serendipity_printArchives() {
...
$entries =& serendipity_db_query("SELECT count(id) ...
$entry_count = count($entries);
...
}

Best Regards

Re: Re: bug in counting entries

Posted: Tue Feb 20, 2007 12:47 pm
by garvinhicking
Hi!

Seems like you used an older version. I just saw the fix you mention is already contained in recent s9y versions; which one are you using?

Best regards,
Garvin