Query: make author query reset callback self-cleaning#176
Draft
dknauss wants to merge 1 commit intohumanmade:developfrom
Draft
Query: make author query reset callback self-cleaning#176dknauss wants to merge 1 commit intohumanmade:developfrom
dknauss wants to merge 1 commit intohumanmade:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Authorship temporarily hooks into WordPress query processing when someone loads author-filtered content. Temporary query hooks should clean themselves up once they have done their work. In this case, the temporary hook was not removed after use over repeated queries. As a result, extra copies of that hook could pile up in memory during the request.
This is a stability and correctness fix to make the temporary hook clean itself up immediately after it handles the query it was created for. This patch keeps the existing author-query rewrite behavior intact, but fixes the callback lifecycle so repeated author-filtered queries do not leave behind extra
posts_pre_querycallbacks that can leak into later requests.Summary
Make the temporary
posts_pre_querycallback used by author-query rewriting remove itself after it has handled the intended query.What changed
WP_Queryinstance that registered itaccumulate
posts_pre_querycallbacksWhy
The current implementation clears stored values after the query runs, but the temporary callback itself remains registered. Repeated author-filtered queries can therefore leave behind extra callbacks on
posts_pre_query.This patch keeps the callback lifecycle aligned with the query it was created for and prevents callback accumulation across later queries.
Scope
This PR is intentionally narrow and limited to query callback lifecycle cleanup.
Included:
inc/namespace.phptests/phpunit/test-wp-query.phpNot included:
Verification
vendor/bin/phpunit --filter TestWPQueryphp -l inc/namespace.phpphp -l tests/phpunit/test-wp-query.php