You signed in with another tab or window.Reloadto refresh your session.You signed out in another tab or window.Reloadto refresh your session.You switched accounts on another tab or window.Reloadto refresh your session.Dismiss alert
This file contains 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
To recap, on thenew theme directory preview, the count of total themes & pages for a given archive would sometimes use the "49 page limit" set inWPORG_Page_Limiter, regardless of logged-in status. This seems to be due to query caching, thefound_postsfilter only runs before caching, not again after returning the cached results. Thefound_postsvalue is cached along with the results, so it's saved when the filter runs for a logged out user, and then returned for a logged in user.
The opposite was also true, logged-out users might see the full 100+ pages available (though attempting to view page 50+ would correctly return a 404).
This PR switches the filter for updatingfound_poststo run onposts_resultsand set the query properties directly. This ensures the filter is run for all queries.
I've also set a custom property on$queryfor the original found_posts value, so that it can be passed through to the Query Total block. Like so:https://github.com/WordPress/wporg-mu-plugins/compare/try/page-limiter-hook— This is a general issue with the page-limit code + Query Total block, we just haven't run into it until now.
To test
View the theme directory
Logged in views should show all pages
Logged out views should show a max of 49 pages
Ensure this works on other sites: News, Patterns, Plugins, etc
I'm going to commit this now since it's a pretty visible bug on the theme directory, and I want to open that to wider feedback today. But feel free to leave any feedback here and I can iterate on it 🙂
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.