Skip to content

feat(migration-media): apply the legacy-host spelling of old-site files - #548

Merged
ABB65 merged 1 commit into
mainfrom
t7/media-apply-legacy-origin
Nov 6, 2026
Merged

ABB65 merged 1 commit into
mainfrom
t7/media-apply-legacy-origin

Conversation

@ABB65

@ABB65 ABB65 commented Nov 6, 2026

Copy link
Copy Markdown
Member

What

Migrate can point the files it left on the old site (studioRecommended) at the address WordPress keeps after the customer's domain moves. It writes a top-level legacyOrigin into media.json, and the delivered repository then names those files at that host, with the path unchanged.

The media apply used to look only for the original address. On such a repository it found nothing and reported every reference as drifted. Now it rewrites both forms of the address to the Studio delivery URL:

  • the original address;
  • the legacy-host address: the same URL with the scheme and host swapped for legacyOrigin.

Unchanged

  • The import still fetches each file from its original address, through the signed origin.
  • studioRecommended[].url stays as Migrate wrote it.
  • Without legacyOrigin, nothing changes.

Parsing

legacyOrigin must be an https origin with no credentials, and it is normalised to URL.origin. Any other value is refused with the usual 422 invalid-manifest error.

Not in this PR

Fetching from the legacy host after the domain has moved. That needs the legacy host to be signed, which is a follow-up. The customer copy tells customers to move these files before moving the domain.

Tests

  • A new unit test applies a legacy-rewritten repository. Exact and contains references (plain and \/-escaped) switch to the delivery URL, nothing is reported as drifted, and an http: legacyOrigin is refused.
  • pnpm test:ci: 2559 unit, 571 integration and 377 nuxt tests pass.
  • pnpm typecheck and lint pass.

When Migrate's delivery points the files it left on the old site at the
address WordPress keeps after the domain move (top-level legacyOrigin in
media.json), the repository names them at that host. The media apply now
rewrites that spelling to the delivery URL as well, so such a repo is
switched to Studio Media instead of being reported as drifted. The fetch
still uses the original address from the signed origin.

legacyOrigin is parsed as an https origin; anything else is refused.
@ABB65

ABB65 commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

ONAY @ce33609: legacyOrigin is parsed strictly (https, no credentials, normalised to the origin, else 422) and only adds a second spelling to the rewrite; fetching still uses the original address. Exact, embedded and escaped forms are covered and drift detection is unchanged. test:ci green per author (unit 2559, integration 571, nuxt 377), typecheck/lint 0.

@ABB65
ABB65 merged commit be82c21 into main Nov 6, 2026
2 checks passed
@ABB65
ABB65 deleted the t7/media-apply-legacy-origin branch November 6, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant