[wp-trac] [WordPress Trac] #36409: Comments number is wrong

WordPress Trac noreply at wordpress.org
Mon Apr 4 15:50:25 UTC 2016


#36409: Comments number is wrong
----------------------------------------+----------------------------------
 Reporter:  sidati                      |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  Future Release
Component:  Comments                    |     Version:  trunk
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  template,
                                        |  performance
----------------------------------------+----------------------------------
Changes (by boonebgorges):

 * keywords:  has-patch => has-patch needs-unit-tests
 * milestone:  Awaiting Review => Future Release


Comment:

 Hi @sidati - Thanks for the patch. I agree that this is unexpected and
 incorrect behavior.

 Your basic idea for fixing it seems right to me. A couple comments on the
 patch:

 - Could you generate it from the root of your WP installation? It makes it
 a bit easier to apply and test.
 - Your `$depth` logic reads backward to me. I mean, I can see that the
 patch works, but I would've counted the depth up instead of down. Maybe
 our minds work differently ;) Anyway, I wonder if the algorithm would be
 more transparent (and less subject to bugs related to
 'thread_comment_depth' if it looked something like this (pseudocode):

 {{{
 $bad_parents = $wpdb->get_col( "SELECT comment_ID from $wpdb->comments
 WHERE comment_approved != 1" );
 $_bad_parents = array();

 do {
     $_bad_parents = $wpdb->get_col( "SELECT comment_ID from
 $wpdb->comments WHERE comment_parent IN (" . implode( ',', array_map(
 'intval', $bad_parents ) ) . ")";
     $bad_parents += $_bad_parents;
 } while ( $_bad_parents );
 }}}

 This separates the initial `comment_approved` query for clarity, and it
 ensures that we keep walking down the tree as long as bad comments are
 found.

 We will also need unit tests to cover the problem.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36409#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list