You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe.
In certain parts of the plugin, custom filters are used to apply changes or functionality to WP_Query queries. The downside of this approach is that it's hard to target queries specifically as any query that occurs after adding to the filter will receive the changes.
I ran into this issue developing the facet block, which uses the ep_is_facetable filter to enable faceting for the queries used to create the block previews. This filter applies aggregations to the query and populates a global variable with the results of those aggregations. I was experiencing an issue where another query was somehow being fired down the chain, which meant that aggregations were also applied to that query and the global variable was populated with aggregations for the wrong query.
A better approach would be to support an ep_is_facetable argument in WP_Query which applies the aggregations to just that query. Then, instead of populating a global variable, the aggregation results could be applied to the query object itself. This keeps everything contained to the specific query that needs to be facetable.
With a quick look I've identified these filters that could use this approach:
ep_is_facetable
ep_intercept_remote_request
ep_bypass_exclusion_from_search
There may be others.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Is your enhancement related to a problem? Please describe.
In certain parts of the plugin, custom filters are used to apply changes or functionality to
WP_Query
queries. The downside of this approach is that it's hard to target queries specifically as any query that occurs after adding to the filter will receive the changes.I ran into this issue developing the facet block, which uses the
ep_is_facetable
filter to enable faceting for the queries used to create the block previews. This filter applies aggregations to the query and populates a global variable with the results of those aggregations. I was experiencing an issue where another query was somehow being fired down the chain, which meant that aggregations were also applied to that query and the global variable was populated with aggregations for the wrong query.A better approach would be to support an
ep_is_facetable
argument inWP_Query
which applies the aggregations to just that query. Then, instead of populating a global variable, the aggregation results could be applied to the query object itself. This keeps everything contained to the specific query that needs to be facetable.With a quick look I've identified these filters that could use this approach:
ep_is_facetable
ep_intercept_remote_request
ep_bypass_exclusion_from_search
There may be others.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: