Make WordPress Core


Ignore:
Timestamp:
10/01/2015 03:57:53 AM (10 years ago)
Author:
boonebgorges
Message:

Prevent extra db queries in WP_Comment::get_children().

WP_Comment_Query::fill_descendants() queries for a comment tree in a way that
minimizes database overhead, and places the located descendants with their
proper parents. However, it doesn't touch leaf nodes - comments with no
children - so future calls to get_children() on those comment objects
result in unnecessary database queries. To prevent this, fill_descendants()
now sets a populated_children flag on all located WP_Comment objects.

See #8071.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r34599 r34730  
    923923            }
    924924
     925            // Set the 'populated_children' flag, to ensure additional database queries aren't run.
     926            foreach ( $ref as $_ref ) {
     927                $_ref->populated_children( true );
     928            }
     929
    925930            $comments = $threaded_comments;
    926931        } else {
Note: See TracChangeset for help on using the changeset viewer.