[wp-trac] [WordPress Trac] #8973: Function get_page_of_comment()
returns incorrect page numbers -- fix included
WordPress Trac
wp-trac at lists.automattic.com
Tue Jan 27 16:54:41 GMT 2009
#8973: Function get_page_of_comment() returns incorrect page numbers -- fix
included
---------------------------+------------------------------------------------
Reporter: GregMulhauser | Owner: anonymous
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.7.1
Component: General | Version: 2.7
Severity: major | Keywords: comments, paging
---------------------------+------------------------------------------------
The function get_page_of_comment(), defined in /wp-includes/comment.php
for WordPress 2.7, returns wildly incorrect results in cases where the
database includes spam trackbacks or pingbacks. The reason is that the DB
query on line 595 does not include "comment_approved = 1" and therefore
incorrectly counts unapproved trackback and pingback spam (not to mention
non-spam comments in moderation). As far as I can tell from browsing my
DB, although spam comments have their comment_type changed to 'spam' in
the database, trackbacks and pingbacks still retain their original
comment_type.
As a newbie to the WordPress Trac, I'm afraid I don't know how to provide
a diff, but the full correct query is as follows:
$oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID)
FROM $wpdb->comments WHERE comment_approved = 1 AND comment_post_ID = %d
AND comment_parent = 0 AND comment_date_gmt < '%s'" . $comtypewhere,
$comment->comment_post_ID, $comment->comment_date_gmt ) );
The upshot is that without the above fix, comment URLs in several places
(e.g., RSS feeds) may point to non-existent pages.
All the best,
Greg
--
Ticket URL: <http://trac.wordpress.org/ticket/8973>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list