Repository navigation
fix(seo): read ?atlas= into the route variable, so a query-routed page declares our canonical instead of contradicting it - #21
Conversation
`sahaj_atlas_current_route()` read one thing: the query var only `sahaj_atlas_parse_request()` sets, and only under path routing. So on a query-routed host every atlas deep link returned `''`, `sahaj_atlas_seo_boot()` returned early, and two things followed: no per-route metadata and no crawlable body content, and no suppression either — core's `rel_canonical` and the host's SEO plugin kept emitting the bare permalink. Each `loc` SahajCloud publishes named a page that named a different canonical. Query routing is permanent for the hosts on it, not transitional: a site with plain permalinks, an atlas at its front page, or a server SahajCloud cannot probe stays there for good. `sahaj_atlas_current_route()` now falls back to `?atlas=`, through the same `sahaj_atlas_clean_route()` sanitiser the block attribute uses, gated on the Atlas page — the parameter is one anyone can append to any URL, and an ungated read would let an arbitrary page claim an atlas route's canonical. `sahaj_atlas_suppress_canonical_redirect()` keys on the path route alone now. A query-routed URL is the page's own permalink plus a parameter, so `redirect_canonical()` has nothing to strip, and widening the filter would disable a core behaviour on every ordinary page load carrying `?atlas=`. `sahaj_atlas_parse_request()` is untouched: a query-routed page needs no rewrite, and its three refusals are what `sahaj_atlas_path_routing_viable()` declares. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM
`tests/seo.php` seeds the endpoint's answer and asserts the takeover itself: the canonical emitted once and equal to the published one, core's `rel_canonical` and shortlink silenced, the title, hreflang, JSON-LD and crawlable body, the root exclusion, a hostile or array parameter refused, and an ordinary page carrying `?atlas=` left alone. `tests/contract.php` now replays the contract's seven `routing: "query"` cases as the parameter they arrive in, alongside the path cases it already replayed as requests, and pins `SAHAJ_ATLAS_QUERY_VAR` to the contract's `queryParam`. The render lane fetches `/find-a-class/?atlas=/nl/amsterdam` on both theme kinds and asserts the rendered `<head>`, not a status code. ⚠ `$_GET` is already slashed when a plugin reads it — `wp_magic_quotes()` runs on every request. A fixture assigning a raw value tests a request WordPress never delivers, and `/\evil.com` passed as `/evil.com` until every case went through `sahaj_set_query_route()`. Each new assertion was watched failing against the reintroduced early return: 21 in the PHP suite, 6 per theme in the render lane. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM
…refs Trap 9 now states which route the canonical-redirect filter keys on. Trap 17 states that the route variable answers both shapes, and why reading `?atlas=` stays gated on the Atlas page. The testing section gains the `$_GET` slashing trap. Five `⚠` line references moved with this diff. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM
The hook comment said `sahaj_atlas_seo_boot()` reads a route the embed resolver already validated. The resolver hard-codes `'atlas' => ''` for the Atlas page, so it validates nothing here — `sahaj_atlas_query_route()` does. Found by the branch security review, which confirmed the code is right and only the comment misattributed the check. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM
Four cleanup agents reviewed the branch for reuse, simplification, efficiency and altitude. Applied: - `sahaj_atlas_seo_slot()` loses its `$locale` parameter. The one production caller passed exactly what the null branch computed, and a caller free to name a different locale writes a transient nothing ever reads — a fixture failure that surfaces as a live request timing out. - `SAHAJ_ATLAS_QUERY_VAR` becomes `SAHAJ_ATLAS_ROUTE_PARAM`. It sat beside `SAHAJ_ATLAS_ROUTE_VAR` reading as though it were a registered query var, which is the one thing it is pointedly not. - `sahaj_atlas_query_route()` unslashes after its type and emptiness guards instead of before, so an array or empty parameter is rejected without walking it. Behaviour is unchanged; `wp_unslash()` never yielded a string from a non-string. - A third `⚠` records why the read is `$_GET` and not a registered query var: a registered var is filled from `$_POST` first, still needs the Atlas page check, claims the bare name `atlas` site-wide, and would be discarded by this file's own `parse_request` handler. - `includes/routing.php`'s header said "Path routing"; the file now owns both shapes. - One SEO answer fixture, `tests/fixtures/seo-answer.php`, replaces three copies — the PHP suite's and one inside each render blueprint's JSON-escaped `runPHP` string. The copies had already diverged on `breadcrumbs`. - `sahaj_query_page()`, `sahaj_clear_query_route()` and `sahaj_seo_untouched()` replace hand-rolled repeats in the new test code. - `sahaj_seo_reset()` drops two `remove_filter` lines no assertion reads. Skipped, with reasons: passing the API key into `sahaj_atlas_seo_slot()` to save one cached `get_option` (the signature is worth more than the lookup); dropping the `'' === $raw` guard as redundant with the sanitiser (it is the early-out that keeps an empty parameter from reaching `is_atlas_page()`); routing the pre-existing `WP_Query` at tests/run.php:197 through the new helper (it is outside this branch's diff, and the helper is defined below it). The 21-red / 6-red-per-theme defect check was re-run after the test rewrite. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Right-sized for #20: ~20 lines of logic, the rest tests, a fixture and AGENTS.md. Path routing is untouched, the ?atlas= read is gated on the Atlas page, and a path route still beats a crafted parameter. sahaj_atlas_seo_slot() is the one thing #20 did not ask for, and it earns its place by deleting a copied md5 recipe from three test sites.
Producer side verified: SahajCloud's canonicalUrlBase() ends a query base at …?atlas= and appends the path raw, so the fixture and SAHAJ_ATLAS_ROUTE_PARAM match what it publishes.
On add_query_arg() not encoding the route: file it separately.
Findings
- should-fix — the rationale at
routing.php:121-124, copied intoAGENTS.mdtrap 9 andtests/seo.php:88-92.
What was checked
- #20 against the diff;
routing.php,seo.php,page.php:36,embed.php:179read. - Contract JSON byte-identical to SahajCloud's;
canonicalUrl.ts:118-134read. - Render lane asserts the
<head>, not a status. - Only
sahaj_atlas_seo_boot()callssahaj_atlas_current_route().
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The rationale on `sahaj_atlas_suppress_canonical_redirect()` claimed that widening the filter to every atlas route would switch `redirect_canonical()` off for any page load carrying `?atlas=`. It would not. `sahaj_atlas_query_route()` already refuses off the Atlas page, so `sahaj_atlas_current_route()` is never non-empty there — tests/seo.php pins exactly that. The decision stands on a different fact. The shared contract publishes `/?p=42&atlas=…` and `/index.php?page_id=7&atlas=…` mounts, and core 301s each to the page's pretty permalink with `?atlas=` intact, since `atlas` is no registered query var for core to consume. That redirect is what carries a query-routed visitor to the canonical URL. Suppressing it would strand them on the mount. A wrong reason in a comment is worse than no reason: the next reader checks it, finds it false, and has to re-derive the decision or undo it. Restated in all three places that carried it — routing.php, AGENTS.md trap 9, and the assertion comment in tests/seo.php — with the wider claim marked as wrong so it does not come back. Line references in AGENTS.md traps 12 and 17 move with the inserted lines. Trap 12 now points at the `⚠` comment the file's own convention promises, rather than a docblock five lines above it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WbVuqAWj1FELcnq4WyYmBy
|
One thread, adopted. No behaviour changed — comments,
Nothing rebutted, nothing asked. Lean gate re-run on 08183d8: 12 files lint clean, 167 assertions / 0 failures, render 0 failures on both theme kinds. Contract file still byte-identical to SahajCloud 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`main` moved under this branch with #21, which rewrote the same two files: `sahaj_atlas_current_route()` now answers for `?atlas=` as well as the path route, and `tests/seo.php` arrived there first, covering the query-routed shape. Both halves are kept; four resolutions were needed. - `sahaj_atlas_seo_cache_key()` is dropped for `sahaj_atlas_seo_slot()`. They are the same helper, written twice. #21's own /simplify pass removed the locale parameter on purpose — a caller free to name a locale writes a transient nothing reads — so the version without it wins, and the slot assertions drive the locale through `determine_locale` instead. - `tests/seo.php` is one file again: #21's routing groups, then this branch's root, opt-out and trap-16 groups. The group asserting the root is *excluded* is now the group asserting it is described, which is the behaviour change this ticket is. - A refused `?atlas=` now falls back to the root view rather than to nothing, since the page is the root view either way. The assertion that matters is the one that survives: the crafted value reaches neither the endpoint nor the canonical. - `tests/fixtures/seo-answer.php` carries the root answer beside the region one, so both render blueprints seed from the one copy. It is seeded under `/search` as well as `/`, because the endpoint answers them alike but the cache is keyed on the route as asked. `pnpm test:all` passes: 220 assertions, and 112 render assertions across both theme kinds. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CyxoefN47eov1tQxCQ4Y7Z
* chore(release): v0.2.0 Three merged changes ship in the plugin zip since v0.1.0, and a volunteer sees none of them until a tag builds one: #21, #23 and #24. Everything else merged since c1fec89 is CI, docs or tests, all of which `.distignore` keeps out of the zip, and #10 and #13 touched shipping files in comments only. Minor, not patch, and pre-1.0 either way: #23 adds a capability and a second site setting, so the version has to move more than a fix would. Four declarations, not two. `release.yml` compares the tag against the plugin header alone, so it would have passed with `SAHAJ_ATLAS_VERSION` left at 0.1.0 — and that constant is the cache-buster on `atlas-page.css`, `atlas-page.js` and the editor assets. Every updated site would have kept serving the 0.1.0 copies. `blocks/embed/block.json` declares the same version to the editor. `package.json` declares none: it is dev tooling, and `.distignore` excludes it. The changelog is written for the one non-technical volunteer who runs each site, so it names what they will see rather than what changed in the code. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QNEAgEV5tDoLsB9nyLUv26 * fix(readme): the 0.1.0 entry claimed a 0.2.0 row #23 edited the shipped `= 0.1.0 =` changelog entry, adding "and which side describes the Atlas page" to the status-panel bullet. That row did not exist at v0.1.0 — `git show v0.1.0:readme.txt` has the panel covering four things, not five. Plugin Update Checker merges readme.txt's sections into the WordPress update modal, so a volunteer on 0.1.0 deciding whether to update reads the fifth row credited to the version they already run. The 0.2.0 entry announcing that same row then reads as a repeat, and the release that actually ships it loses the credit. A shipped release's entry describes what that release shipped. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jg5XawkJdwdSyhgVGdkvQu --------- Co-authored-by: Claude <[email protected]>
Summary
rel_canonicaland the host's SEO plugin are suppressed on those pages, so each one stops contradicting the canonical the sitemap points at.Changes
includes/routing.php—sahaj_atlas_current_route()falls back to?atlas=, gated on the Atlas page; the canonical-redirect filter keys on the path route alone.sahaj-atlas.php—SAHAJ_ATLAS_ROUTE_PARAM, pinned to the shared contract'squeryParam.includes/seo.php— the transient key moves intosahaj_atlas_seo_slot(), so a fixture seeds the cache through the plugin's own builder rather than a copy.includes/routing.php,AGENTS.md,tests/seo.php— the rationale for keying the canonical-redirect filter on the path route, restated after review (08183d8). See Notes for reviewer.Contract impact
tests/atlas-url-contract.jsonis untouched and verified byte-identical to SahajCloud's copy. What changes is that this plugin now answers the contract's sevenrouting: "query"cases as well as its path cases —tests/contract.phpreplays both halves. Named but not filed by sydevs/SahajCloud#644; the two changes stay independent.Test results
pnpm test:all— 12 files lint clean, 167 assertions / 0 failures, render 0 failures across both theme kinds. Re-run on 08183d8, same result.tests/atlas-url-contract.jsondiffs clean against SahajCloudmain/security-reviewover the diff (^includes/|^sahaj-atlas\.phpmatchessecurityReview.triggerPattern) — no findingsManual verification
routing: query, open an atlas deep link and view source: one<link rel="canonical">, matching thelocin/sahaj-atlas-sitemap.xml.Notes for reviewer
The judgement call worth checking is the split between
sahaj_atlas_current_route()andsahaj_atlas_path_route(). The ticket said to leavesahaj_atlas_suppress_canonical_redirect()"correct for both", and to check rather than assume. Checking said the two want different answers — but not for the reason first recorded here, which the adversarial review then caught and 08183d8 corrects.The false reason: that widening the filter would switch
redirect_canonical()off for any page load carrying?atlas=. It would not.sahaj_atlas_query_route()refuses off the Atlas page, so an ordinary page load never reaches a non-empty route, andtests/seo.phpasserts exactly that.The real reason: the contract publishes
/?p=42&atlas=…and/index.php?page_id=7&atlas=…mounts, and core 301s each to the page's pretty permalink with?atlas=intact —atlasis no registered query var for core to consume. That redirect is what carries a query-routed visitor to the canonical URL. Suppressing it would strand them on the mount. So the filter keys on the path route, which is byte-identical to today's behaviour, and the tests pin both directions.Detail
Why the Atlas page gate is load-bearing.
?atlas=is a parameter anyone can append to any URL on the site, andsahaj_atlas_current_route()feedssahaj_atlas_seo_boot(). Without the gate an arbitrary page could be talked into claiming an atlas route's canonical as its own.sahaj_atlas_seo_boot()checks the same thing, but the guarantee belongs where the parameter is read.Why
$_GETand not a registered query var. Recorded as a third⚠on the function. A registered var is filled from$_POSTbefore$_GET, so the route would become accepted from a request body; it would still need the Atlas page check, sinceget_query_var()answers on every page; it would claim the bare nameatlasacross the host's whole site; andsahaj_atlas_parse_request()replaces$wp->query_varswholesale, so it would be discarded on the path-routed requests. It also keepsredirect_canonical()from consumingatlason the mount shapes above.The sanitiser is the existing one.
sahaj_atlas_clean_route(), the same function the block and shortcode attribute already use. A value it refuses leaves the route empty, so the page falls back to the host's own metadata rather than emitting a wrong canonical. An unresolvable route is refused one step later: the endpoint 404s it andsahaj_atlas_seo_fetch()caches the miss.sahaj_atlas_parse_request()is untouched, as the ticket asked. A query-routed page needs no rewrite — WordPress already served it — and its three refusals are whatsahaj_atlas_path_routing_viable()declares to SahajCloud#644's probe.Fixture pre-mortem.
tests/fixtures/seo-answer.phpis oneAtlasSeoResponse, shared by the PHP suite and both render blueprints. Its shape was verified againstsrc/endpoints/responseTypes.ts:149-188in sydevs/SahajCloud (AtlasSeoBase,AtlasSeoRegionContent,AtlasSeoEventCard), not invented from this plugin's reader — a fixture derived from the reader would only assert that the reader reads itself.⚠ A trap this cost one round.
$_GETis already slashed when a plugin reads it;wp_magic_quotes()runs on every request, so the plugin unslashes. A fixture that assigns a raw value therefore tests a request WordPress never delivers —/\evil.comsailed through as/evil.comuntil every query-routing case went throughsahaj_set_query_route(), which slashes first. Recorded inAGENTS.mdand attests/run.php:242.⚠ A wrong reason costs more than no reason. The rationale corrected in 08183d8 read plausible and survived a whole implementation round. The next reader checks it, finds it false, and then has to re-derive the decision or undo it. All three copies now carry the real reason and mark the wider claim wrong, so it does not come back.
Each new assertion was watched failing. With the early return reintroduced: 21 red in the PHP suite, 6 per theme in the render lane. Restored, all green. Re-run after the cleanup pass rewrote the assertions' shape.
The
/simplifypass is the last code commit. Four cleanup agents (reuse, simplification, efficiency, altitude) reviewed the branch; that commit's body lists what was applied and what was skipped, with reasons.add_query_arg()does not URL-encode its values, so a route splices raw into the outbound endpoint request. The security review traced it and declined to report it: the caller already controlsroutelegitimately, the only other parameter islocale(affecting that request's own answer), the answer caches under its own transient slot, and the host, path andAuthorizationheader are unreachable. Not exploitable today, and it predates this branch — a path route can carry&too. Worthrawurlencode()if/api/atlas/seoever grows a parameter that matters. Left alone rather than widening this PR; say the word and I will file it.One pipeline step did not run.
/pr-review-toolkit:review-pris not available in this session, so the six-lens review was not performed./simplifyand/security-reviewwere.Closes #20
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_013q7a2QtKsRJLAwYyfZwYUM