weird archive issue

Found a bug? Tell us!!
Post Reply
n2ition
Regular
Posts: 58
Joined: Sun Mar 20, 2005 8:43 pm
Location: Dallas, TX
Contact:

weird archive issue

Post 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! :)
The good news is the bad news is wrong! Random Kindness Project
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Last edited by judebert on Wed Jan 25, 2006 5:35 am, edited 2 times in total.
Judebert
---
Website | Wishlist | PayPal
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
n2ition
Regular
Posts: 58
Joined: Sun Mar 20, 2005 8:43 pm
Location: Dallas, TX
Contact:

Post 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.
The good news is the bad news is wrong! Random Kindness Project
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
n2ition
Regular
Posts: 58
Joined: Sun Mar 20, 2005 8:43 pm
Location: Dallas, TX
Contact:

Post by n2ition »

perfect...that did it!

Thanks. :D
The good news is the bad news is wrong! Random Kindness Project
Post Reply