Page 1 of 1
weird archive issue
Posted: Wed Jan 25, 2006 1:08 am
by n2ition
This issue began after I upgraded to v 0.9. The archives are showing incorrect number of entries when you select the "Older" option on the side bar. In November I only made 2 entries on my blog...but by selecting the "Older" link it lists there were 8 posts made. The same is true for this month. So far I have posted 10 posts this month...but the recap under the archive link is showing 22.
Any help you all can give would be much appreciated.
Thanks!

Posted: Wed Jan 25, 2006 5:07 am
by judebert
I've had the same problem before.
At one point, the category plugin was counting drafts as well as published entries. Do you suspect the archive plugin is doing the same? The category issue was fixed in v0.9.1. Of course, we're talking about the archives, here.
Personally, I think it's counting the categories, not the entries. So if you had 2 entries, but one of them was in 3 categories, it would report 4 entries.
The SQL in functions_entries.inc.php looks like: "select entries e left join entrycat ec on e.id = ec.entryid left join categories c on e.catid = ec.catid;". So if an entry had two categories, that would select two rows (because two entrycat rows would match the id), then add a the category columns matching the categories. Two rows for one entry.
I just checked in my own blog, running 1.0-alpha2, and it's counting categories, not entries. Garvin, I'm not seeing that $entries array used anywhere else, at least not before the end of the function; could we change the SQL to
Code: Select all
"SELECT id
FROM {$serendipity['dbPrefix']}entries e
WHERE isdraft = 'false'
AND timestamp >= $s
AND timestamp <= $e "
. (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : '')
. (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . "
Removing the joins would certainly speed things up.
Posted: Wed Jan 25, 2006 5:30 am
by judebert
Well, I tested it on my blog, and that makes the archive bars the correct size. But that wasn't the problem, and the sidebar is still wrong. I'll keep looking.
Posted: Wed Jan 25, 2006 6:05 am
by judebert
Okay, I think I'm finally on the right track now. In plugins_internal.inc.php, around line 494 or so, you'll see this command:
Code: Select all
$ec = serendipity_fetchEntries(
array($current_ts, $end_ts),
false,
'',
false,
false,
'timestamp DESC',
'',
false,
true,
'count(e.id) AS orderkey',
'',
'single'
);
If you change "count(e.id)" to "count(
distinct e.id)", your sidebar counts will become correct. Mine did, anyway.
Posted: Fri Jan 27, 2006 12:51 am
by n2ition
I upgraded to v 0.9.1 and looked for the lines of code you listed but have been completely unsuccessful in locating them. Could it be they are written differently for the beta release you are using. Or possibly in a different file? I'm still having the same problem even after the upgrade.
Posted: Fri Jan 27, 2006 6:04 am
by judebert
Having just installed 0.9.1, I'm not seeing any counts in the archive links themselves. So that must mean your archive bars have the wrong count.
Just checked it on mine, and it's counting categories for the bars.
Well, this is fixed in 1.0-alpha2 (at least) and above; upgrading is the easiest course.
Of course, if you want to do it the hard way... look in functions_entries.inc.php. On line 1128, you should see "SELECT count(id)". Change it to "SELECT count(distinct e.id)" and your bars should be fixed.
Except it's not working for me. Sigh. I'm sorry, but I'm going to have to go to bed now. I'll keep working on this later.
Good night. Oh, wait! It did work for me! I just needed to type it exactly as above. Phew. Now I can rest easy.
Posted: Mon Jan 30, 2006 12:54 am
by n2ition
perfect...that did it!
Thanks.
