Analyse the facets proposal - #166
Open
titouanmathis wants to merge 4 commits into
Open
Conversation
wordpress-project!715 proposes facet filtering by copying a request array into WP_Query. Record why that must not be ported — it is an unauthenticated query var injection, and its parameter names cannot be a cache key in nginx at all — and what the page cache still needs before a facet can be cached. Co-authored-by: Claude <claude@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #166 +/- ##
=========================================
Coverage 85.66% 85.66%
Complexity 2535 2535
=========================================
Files 194 194
Lines 6988 6988
=========================================
Hits 5986 5986
Misses 1002 1002
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two of the four items are done and one was built and removed. Record the differences — ordering did not need solving, the two configs stayed independent, search needed no new switch — and what is left: a bound on the key space, and an example that shows a filter form working end to end. Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude <claude@anthropic.com>
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.
.planning/research_facets.md— whether Føhn can already do what wordpress-project!715 proposes, and what the page cache still needs before a facet can be cached. No code changes.The short version
The filtering already exists.
QueryFiltersHookandQueryFiltersConfigare the allowlisted version of the proposal'sFacetsManager, and the native WP vars (?s=,?cat=,?tag=,?orderby=) need no code at all. The proposal's client-side half — a real GET form enhanced byFrame/FrameTarget— is good and worth keeping.Its parameter naming must not be ported, and the reason is not style:
facets[tag_id]cannot be a cache key. It reaches the wire asfacets%5Btag_id%5D;QueryKeynever decodes,getCacheQueryArgs()only keys names matching^[A-Za-z0-9_-]{1,32}$, and nginx has no$arg_facets[tag_id]to read it with. Every faceted request is a bypass on every hit.$query->query_vars[$key] = $valuefor every key in the request makes?facets[posts_per_page]=-1,?facets[orderby]=randand arbitrarymeta_querypublic URLs.What the analysis found beyond the proposal
Flattening the names is not enough. Two walls remain in Føhn itself:
?genre__and=rock,jazz— the formatdocs/guide/query-filters.mddocuments — bypasses the cache, becauseQueryKey::VALUE_CHARACTER_CLASShas no comma and a project pattern can only narrow it. The array form fails too:[is invalid in a keyed name and a repeated name is an explicit bypass. The framework's own documented filter URL format is exactly the format its page cache refuses.is_searchis an unconditionalBypassReason::Search.So the work, in order: a multi-value encoding the cache can key (with canonical ordering as the real design question, since nginx cannot sort), then deriving
cacheQueryArgsfrom the declared filters so the two lists cannot drift, then a bound on the key space, and search only if the keyword field has to be cached.Two decisions are recorded as open: Section Rendering and a cached facet response are mutually exclusive today (
foehn_sectionsisno-storeand unkeyable), and filtered counts stay out of scope.The document also lists six defects in the proposal's diff itself, including filters applied to every query on the page for want of an
is_main_query()guard, and a "Last" pagination button that links to the first page.🤖 Generated with Claude Code
https://claude.ai/code/session_01KZusb9DU8coizq3CDgHEqi