[wp-trac] [WordPress Trac] #36687: Feature to override WP_Query to provide results from other source

WordPress Trac noreply at wordpress.org
Wed Jun 15 07:55:37 UTC 2016


#36687: Feature to override WP_Query to provide results from other source
-----------------------------------+--------------------------
 Reporter:  jpdavoutian            |       Owner:  jpdavoutian
     Type:  feature request        |      Status:  reopened
 Priority:  normal                 |   Milestone:  4.6
Component:  Query                  |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+--------------------------
Changes (by dd32):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 @boonebgorges This change has broken at least one implementation of a
 plugin inserting it's own posts data.

 In this case, it's a Jetpack Search implementation -
 https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html
 /wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php

 It's a bit convoluted to follow, but the basic principle is that it hooks
 into `the_posts` to add the posts and `found_posts` to add the found posts
 counts. However, the issue is that previously `$this->set_found_posts( $q,
 $limits );` was run regardless of if `$this->posts` actually contained any
 results, but it now is only run on line 3656 if data was retrieved from
 the database.

 It seems like `set_found_posts` has some strange logic in it `( is_array(
 $this->posts ) && ! $this->posts )` which works around this case, so I
 think the safest bet might be to always call the method regardless of if
 posts were found.

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


More information about the wp-trac mailing list