Repository navigation
fix: localized SEO for national sites, clean query routes, release-only updates - #73
Conversation
`sahaj_atlas_seo_locale()` sends `nl-NL`, `de-DE` and the like, while SahajCloud lists only exact codes (`nl`, `de`, …, plus `en-AU` and `pt-BR`). The endpoint answered 400, the one retry asked with no locale at all, and most national sites got the English root title and description. A refused tag is now retried as its bare language first, then with no locale, so `nl-NL` reaches `nl` and `pt-BR` still matches exactly. The plugin still keeps no copy of the locale list. The answer is cached in the same slot as before. There was no test of this retry. One now proves an nl_NL site asks for `locale=nl` once `nl-NL` is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The widget nests its own view state in `?atlas=` (`?atlas=/nl/amsterdam%3Fcenter%3D4.9,52.3`), which `$_GET` decodes to a route carrying `?center=…`. That route went upstream as-is, and SahajCloud 404s it, so a shared map link lost its SEO takeover. Only the part before `?` or `#` is the route now. `add_query_arg()` encodes nothing, so the route, the key and the other values reached the script URL and the SEO request raw, where an `&` in a route would start a parameter of its own. Both now pass through `rawurlencode_deep()`, as embedding.md asks; it lists `atlas=%2Fgb%2Flondon` and `atlas=/gb/london` as equivalent. The assertions that matched a raw `/` now match `%2F`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
REQUIRE_RELEASE_ASSETS alone made Plugin Update Checker fall through to the latest tag and install GitHub's source archive anyway, so the strategy filter keeps only the latest release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Three commits, three behaviours, each with an assertion watched failing first. The diff is the size of the problem, with nothing to cut. Both premises hold upstream: SahajAtlasWeb src/lib/shape/query.ts:13 and path.ts:83 show the widget really does nest view state inside atlas=, and docs/embedding.md:132 states atlas=%2Fgb and atlas=/gb are equivalent, so rawurlencode_deep() is contract-safe and the loader decodes through URLSearchParams. The locale ladder is right to keep no copy of the list: SahajCloud's isValidLocale() is an exact match over 19 codes, nl-NL and pt are both absent, and the bare-language rung is what reaches nl. My one objection is updates.php, whose single non-platform-native line pins the vendored PUC minor version.
Findings
should-fix—includes/updates.php:60pinsv5p6in a literal; a PUC bump makes it a fatal oninit. The constants are on$api.consider—tests/run.php:725asserts against a hand-written array, so a PUC key rename passes while updates stop silently.
What was checked
- Read whole:
updates.php,seo.php,routing.php,embed.php:262-400. - Ladder: no new file, function or constant.
rawurlencode_deep()andstrcspn()are core and PHP, the retry a three-valueforeach. - Vendor:
Puc/v5p6/Vcs/Api.php:11-39,GitHubApi.php:358-374,ReleaseAssetSupport.php:38,load-v5p6.php. Nov5\Vcs\Apialias;$branchdefaults tomaster, solatest_releaseis present today. - Consumers:
src/loader/config.ts:167-190,literals.ts:40;atlas/seo/index.ts:88-97,lib/locales/index.ts:14-32;tests/atlas-url-contract.json— 21 cases, none nesting a?. wp_unslash()still precedes the truncation, so/\evil.comstays refused.settings.php:343, the thirdadd_query_arg, takes static admin args only.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The class literal spelled the vendored minor version, `v5p6`, four lines under the `v5\PucFactory` entry point chosen to avoid exactly that, and `load-v5p6.php` registers no version-free `v5\Vcs\Api` alias. The next `vendor/plugin-update-checker` bump would have turned both constant reads into a `Class not found` fatal on `init`, on all thirteen sites at once. `pnpm lint` checks syntax, so nothing here would have caught it first. The constants sit on the abstract `Vcs\Api` the instance in hand already extends, so reading them off `$api` carries no version at all. Addresses #73 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXNHRk6rsXrYsS3a4a
The expectation was built from a hand-written array, so it proved `array_intersect_key` and not the coupling it was written for. `GitHubApi::getUpdateDetectionStrategies()` adds `latest_release` only on branch `master` or `main`. The day that key leaves its set, the filter returns an empty array, PUC chooses no reference, and no site is offered an update again — silently, since no diagnostics check covers updates, while a literal key keeps the assertion green. The strategies now come from PUC, keyed by the constant rather than its spelling. The key's presence and the fallbacks beside it are asserted on their own, so a filter that returns nothing cannot read as a pass. Both new assertions were watched failing: keeping `STRATEGY_LATEST_TAG` instead fails the drop assertion, and a branch PUC offers no release for fails the presence one. Addresses #73 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXNHRk6rsXrYsS3a4a
|
Both critic threads adopted.
Both new assertions were watched failing: keeping
The security review ran on 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
* fix(seo): read a variant locale's language instead of dropping it `sahaj_atlas_seo_locale()` anchored its pattern at `xx` or `xx-YY`, so a WordPress locale spelled any other way matched nothing, the SEO request carried no `locale`, and SahajCloud answered in English. #73 fixed the regional case by retrying a refused tag as its bare language, but a locale that never matched never entered that chain. Real locales this refused: `de_DE_formal`, `nl_NL_formal`, `pt_PT_ao90`, `de_CH_informal`, and every three-letter language such as `ckb`, `bal` and `rup_MK`. A site set to "German (Formal)" handed crawlers the English title and description. Read the first two subtags and ignore whatever follows them, and let the language subtag be two or three letters. The retry chain already drops a refused tag to its bare language and then to no locale, so nothing else changes and the plugin still keeps no copy of SahajCloud's locale list. The new `tests/seo.php` group walks all three hops with every locale refused, and pins that a value with no language subtag still sends none — the guard the widened pattern needs. Closes #80 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXvebmSqNbgVwW3jam * refactor(test): one locale stub and one refusal stub, not four and two The locale group added a `determine_locale` returner and a `pre_http_request` refusal stub beside the ones the regional group already had, so the file carried four one-line locale functions and two copies of the endpoint's 400 shape. Each also needed its own hand-paired add_filter/remove_filter, and an unmatched one leaks a locale into every group below. The locale is now a global one filter reads, and the refusal pattern is a third argument to `sahaj_seo_stub()`, which `sahaj_seo_http_stub()` already owned the response shape for. Both refusal stubs go. `sahaj_seo_asked_locale()` replaces the hand-rolled URL probe in six assertions, so `sahaj_is` can print the locale a failing hop actually asked for instead of `false`. Both halves were watched failing: the old pattern still fails four of the new assertions, and a refusal pattern that matches nothing still fails the regional group's two. The production comment moves the locale inventory into the docblock and keeps only the constraint, the #80 breadcrumb and why the refusal branch stays. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXvebmSqNbgVwW3jam * docs(seo): give the locale ⚠ the backtracking why The first two sentences restated the pattern and the pattern it replaced, neither of which a fresh reader of this file can see. What was missing is why the trailing `(?:-|$)` is there at all: without it a two-letter variant subtag backtracks into the region group and `be_tarask` asks for `be-TA`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYThPkR3z8N5N9mYEL --------- Co-authored-by: Claude <[email protected]>
Fixes from a workspace-wide audit. One commit per behaviour. The owner approved each behaviour change.
What changes
fix(seo)a refused regional locale asks again in its bare languagenl_NLbecamenl-NL, and SahajCloud accepts only exact codes (nl,de, … plusen-AU,pt-BR). It answered 400, the plugin retried with no locale, and most national sites got English titles, descriptions and crawlable body. The fetch now tries the tag, then its base language, then none. There is still no hard-coded locale list.fix(routing)the widget's view state is not part of the route?atlas=/nl/amsterdam?center=4.9,52.3was sent upstream whole, SahajCloud 404'd the?, and shared links indexed as the generic root. The route now stops at?/#. Bothadd_query_argcalls takerawurlencode_deep, asembedding.mdasks.fix(updates)offer an update only from a release carrying the built zipREQUIRE_RELEASE_ASSETSalone falls through to the latest tag, so a strategy filter keeps onlylatest_release. Therelease.ymlcomment ("a release without the asset delivers nothing") is now true.fix(updates)read PUC's release constants off the API instancev5p6, four lines under thev5\PucFactoryentry point chosen to avoid exactly that, andload-v5p6.phpregisters no version-freev5\Vcs\Apialias. The nextvendor/plugin-update-checkerbump would have made both constant reads aClass not foundfatal oninit, on all 13 sites at once, andpnpm lintchecks syntax. The constants sit on the abstract class the instance already extends.test(updates)assert the filter against PUC's own strategy setarray_intersect_keyand not the coupling.GitHubApi::getUpdateDetectionStrategies()addslatest_releaseonly on branchmasterormain. The day that key leaves its set, the filter returns an empty array, PUC chooses no reference, and no site is offered an update again — silently, since no diagnostics check covers updates.Tests
pnpm test:allpasses end to end: lint checks 15 files with 0 syntax errors, the measure lane reports 0 failures, the WordPress 6.7 / PHP 7.4 suite reports 432 assertions and 0 failures, and every render cell passes.origin/maincode, the two newest against a reintroduced defect.Sibling PRs (same audit)
🤖 Generated with Claude Code