[wp-trac] [WordPress Trac] #27571: WP_Comment_Query::query() querying for too much data

WordPress Trac noreply at wordpress.org
Wed Feb 18 20:22:55 UTC 2015


#27571: WP_Comment_Query::query() querying for too much data
--------------------------+-----------------------------
 Reporter:  mkilian       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Comments      |     Version:  3.8.1
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  has-patch 4.0-early => needs-patch


Comment:

 Thanks for posting, mkilian. As you note, there are likely plugins etc
 that are depending on this data being present, and for this reason it's
 probably not going to work to make the simple change that you've suggested
 here.

 A more robust fix would be something like this. Introduce a `WP_Comment`
 class, with a magic method `__get()` that will populate the post-related
 variables only if they're requested (and will respect the cache, etc). In
 `WP_Comment_Query`, only pull up comment-related data - as you suggest in
 your patch - and then convert it to `WP_Comment` objects before returning.
 This way, we preserve backward compatibility while improving performance
 in the way you've suggested.

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


More information about the wp-trac mailing list