[wp-trac] [WordPress Trac] #45800: Add short circuits for WP_Comment_Query

WordPress Trac noreply at wordpress.org
Wed Jun 12 14:23:31 UTC 2019


#45800: Add short circuits for WP_Comment_Query
--------------------------------------+------------------------------
 Reporter:  spacedmonkey              |       Owner:  adamsilverstein
     Type:  enhancement               |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.3
Component:  Comments                  |     Version:  3.1
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by felipeelia):

 Thanks for replying, @spacedmonkey.

 This line (present on our both patches), says it would have to stop any
 queries running:

 `$this->assertSame( $num_queries, $wpdb->num_queries );`

 This test failed here using your patch, by the way.

 Also, if it should only return comment ids, the argument description in
 your patch should be changed from `Return an array of comment data to
 short-circuit WP's comment query` to `Return an array of comment ids to
 short-circuit WP's comment query`, explaining that the user should return
 the actual data somewhere else.

 For `sites_pre_query` and `networks_pre_query` filters, yeah, the
 programmer would have to use another filter to really set the data but for
 `posts_pre_query` and `users_pre_query`, it's possible (and, as far as I
 got it, the expected behavior).

 I can be missing some obvious things here. If so, sorry in advance :) As
 I'm trying to learn here, inside
 `test_comments_pre_query_filter_should_bypass_database_query` you're
 creating a `$result` var that isn't used. Is there any difference between
 instantiating the `WP_Comment_Query` class and then calling its `query`
 method from calling it directly with the query args? Thanks!

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


More information about the wp-trac mailing list