Opened 7 years ago
Closed 21 months ago
#41700 closed enhancement (maybelater)
New filter return in WP_Query
Reported by: | spacedmonkey | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5 |
Component: | Query | Keywords: | has-patch |
Focuses: | performance | Cc: |
Description
WP_Query as multiple return points in get_posts method. This makes adding caching or generally short circuiting, hard. When fields 'ids' or 'id=>parents' many of the filters are bypassed. There should be a filter that all return types run through.
Attachments (2)
Change History (4)
Note: See
TracTickets for help on using
tickets.
I have a plugin that caches the result of WP_Query called enhanced post cache. It hooks into
posts_request_ids
andposts_results
to get values before and after the posts / found posts queries run. It stores a list of post_ids and the found posts value in object cache. This results in no more queries running if value is in cache.This plugin relays these two filters to do the caching. However, if you run a query, with fields 'ids' or 'id=>parent', neither of these filters are run as both return early. Now these was a new filter added in 4.6 called
posts_pre_query
that runs before all types of queries. This can be used to load posts in from another source and stop queries from running, similar toposts_request_ids
. However to be able to cache the values, there needs to be a filter that runs after values are set. This new filterpost_query_return
fixes this issue and adds a filter that runs, no matter the return type.