Trackback/Comments counter not reliable in bullet proof?

Skinning and designing Serendipity (CSS, HTML, Smarty)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Thanks a lot for detecting this. There was an actual typo inside the code that used the wrong variable.

I committed a fix to SVN! Basically it was just this code in functions_comments.inc.php:

Code: Select all

    $query = "UPDATE {$serendipity['dbPrefix']}entries 
                 SET comments      = " . (int)$counter_comments['counter'] . ",
                     trackbacks    = " . (int)$counter_comments['trackbacks']. ", 
                     last_modified = ". $lm ." 
               WHERE id = ". (int)$entry_id;
    serendipity_db_query($query);
which needs to read:

Code: Select all

    $query = "UPDATE {$serendipity['dbPrefix']}entries 
                 SET comments      = " . (int)$counter_comments['counter'] . ",
                     trackbacks    = " . (int)$counter_tb['counter'] . ", 
                     last_modified = ". $lm ." 
               WHERE id = ". (int)$entry_id;
    serendipity_db_query($query);
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

garvinhicking wrote:Thanks a lot for detecting this. There was an actual typo inside the code that used the wrong variable.

I committed a fix to SVN!
Hohum. I just noticed I'm still getting this with the latest svn snapshot while testing a new template..?

Actually, the number of comments is increased if I add another comment to an entry. Unfortunately, that entry was the only one in my test blog with "old" comments, so I just now forfeited my chance to test it again. Duh! :roll:

However, before this, my commented article showed "0 comments" (it had 2) until I added another one. Then it was updated correctly to "3 comments". (Yes, I checked it with a different template before adding the extra comment.)

Maybe this still isn't fixed properly?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

This might only have happend for your old entries where a wrong count was stored. The fix applies only to new entries, so any comments that were added in the 1.4 cycle before the fix got committed, the comment count there would be wrong.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Guess what... me too. And this is in 1.3.2 (never released)..... now I was helping Judebert troubleshoot some of this stuff, and I think it was related to entry previews.....

Can we get a quick sql command that will re-count comments and trackbacks so they are again accurate?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yeah, the forum search revealed this SQL:

http://board.s9y.org/viewtopic.php?t=12 ... mments+set

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Thanks Garvin. Using that sql, one of my entries now says it has 5 comments and no trackbacks, when in fact it has 4 comments and 1 trackback.
=Don=
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I think what you need is this:

Code: Select all

UPDATE serendipity_entries AS e SET e.comments = ( SELECT count( c.entry_id )
FROM serendipity_comments AS c
WHERE c.entry_id = e.id
AND c.status = 'approved'
AND c.type = 'NORMAL' ) , e.trackbacks = (
SELECT count( c.entry_id )
FROM serendipity_comments AS c
WHERE c.entry_id = e.id
AND c.status = 'approved'
AND c.type = 'TRACKBACK' ) 
There may be a smaller way to write this, but only Garvin would know. My SQL skills are rudimentary.
Judebert
---
Website | Wishlist | PayPal
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I committed a change to BP substantially similar to what I posted on the first page of this thread. The change adds classes for double opt-in comment subscriptions. For those who care, this is the change to content.tpl:

Code: Select all

{elseif $subscribe_confirm_error}
    <div class="serendipity_Entry_Date">
        <h3 class="serendipity_date">{$CONST.ERROR}</h3>
        <div class="serendipity_msg_important comment_subscribe_error">{$content_message}</div>
    </div>
{elseif $subscribe_confirm_success}
    <div class="serendipity_Entry_Date">
        <h3 class="serendipity_date">{$CONST.SUCCESS}</h3>
        <div class="serendipity_msg_notice comment_subscribe_success">{$content_message}</div>
    </div>
The modification will use bp's existing classes for important (red text) and notice (green text) if nothing else is defined by a colorset, or the new classes can be used to override/supplement those.
=Don=
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Re: Trackback/Comments counter not reliable in bullet proof?

Post by blog.brockha.us »

Thanks, judebert, for your SQL snippet, I was too lazy all the time to do it on my own. ;)

I paused blogging for half a year and started again now. Is there already a fix for the problem clearing trackback and comment counters? In the meantime nearly all newer articles of my blog were cleared, because they get new comments / trackbacks. Is it worth start upgrading for that matter?

Later: Upgraded my S9Y installation to the new 1.5 alpha version, I found in the repository. Yep! The problem seems to be fixed now! I will watch this topic a little, but thanks for now! :)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Trackback/Comments counter not reliable in bullet proof?

Post by Don Chambers »

Welcome back!! 8)
=Don=
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Re: Trackback/Comments counter not reliable in bullet proof?

Post by blog.brockha.us »

Thanks, Don. :D
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Post Reply