Remove page-based versioning system, add URL bridge middleware (#452)#453
Merged
Conversation
Member
Author
claude code |
95990a5 to
58054d9
Compare
thibaudcolas
approved these changes
Jul 9, 2026
Comment on lines
+29
to
+30
| rest = match.group("rest") | ||
| parsed = urlparse(rest) |
Member
There was a problem hiding this comment.
just rest should be enough no?
2 tasks
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.
Fixes #452
Description
Removes the existing page-based versioning system (which treated Wagtail versions as fake Locales via
LANGUAGE_CODEsuffixes likeen-6.0.x) and replaces it with a lightweight URL bridge middleware. Old version-suffixed URLs (e.g./en-6.0.x/how-to-guides/manage-snippets/) now 302-redirect to the bare-locale URL with a?target_version=query param:/en/how-to-guides/manage-snippets/?target_version=6.0.x.Why this approach
The fake-locale design required monkey-patching Django's language-code regexes, a cartesian product of
LANGUAGES × WAGTAIL_GUIDE_VERSIONS, duplicate HomePage/content trees per version, and complex version-combo fallback logic. Collapsing to bare locales (en,nl,pt-br) eliminates all of that while the bridge middleware keeps existing external/en-X.x/links working — staged rollout without breaking saved URLs.Areas requiring careful review
apps/core/middleware.py— newVersionedUrlRedirectMiddleware. Regex is strict (latest | N.N.x | N.x), non-GET passes through (no form-submit redirects), 302 (to be flipped to 301 after a week of clean logs). Wired ABOVELocaleMiddlewareso the dotted prefix never reaches locale activation.apps/guide/settings/base.py—WAGTAIL_GUIDE_VERSIONSdeleted,LANGUAGES = WAGTAIL_GUIDE_LANGUAGES(bare codes),LANGUAGE_CODE = "en". This is the root unblock; every downstream edit depends on it.apps/core/migrations/0007_initial_footercontent.py— edited historical migration: hardcoded"en-latest"lookup →"en". Safe because prod already has0007applied (won't re-run); only fresh test/new installs re-run the edited version.apps/core/models/home.py—get_fallback_pagessimplified to plain translation fallback (no version matrix). The oldrsplit("-", 1)would crash on bare locale codes.Testing
New middleware test file
apps/core/tests/test_versioned_url_redirect.py— 7 dedicated tests forVersionedUrlRedirectMiddleware:poetry run python manage.py test apps.core.tests.test_versioned_url_redirect -v 2Manual QA worth doing
curl -I localhost:8000/en-6.0.x/how-to-guides/manage-snippets/— confirm 302 to/en/how-to-guides/manage-snippets/?target_version=6.0.x.LocaleURLMixinremoval affectsContentPage'sget_url_parts).Out of scope (follow-up)
Localerows + page trees from the prod DB. To be done after this is deployed and stable.prompts/content/regeneration — thefetch_content.pyscript is already updated to useen, but re-running it against the live site should happen after deploy. A separate PR will regenerateprompts/content/en/and delete the staleen-latest/directory.AI usage
The
AI (opencode / glm-5.2) assisted with this PR description ,discussion and review throughout the implementation.
all code is reviewed by me