Skip to content

[Remote] Resolve the "latest" WordPress alias before comparing versions - #4247

Open
amitraj2203 wants to merge 1 commit into
WordPress:trunkfrom
amitraj2203:fix/resolve-latest-wp-version-alias
Open

[Remote] Resolve the "latest" WordPress alias before comparing versions#4247
amitraj2203 wants to merge 1 commit into
WordPress:trunkfrom
amitraj2203:fix/resolve-latest-wp-version-alias

Conversation

@amitraj2203

@amitraj2203 amitraj2203 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Motivation for the change, related issues

Fixes #4246.

Every default Playground boot logs a mismatch that isn't one:

Loaded WordPress version (7.0) differs from requested version (latest).

The website defaults wp to the literal string latest (resolve-blueprint-from-url.ts:223). requestedWordPressVersion stored that alias verbatim, while finalizeAfterBoot() compared it against the resolved build version from getLoadedWordPressVersion() — so 'latest' !== '7.0' warned even though the
correct build had loaded.

nightly was already normalized to trunk, and beta/trunk are real keys in wp-versions.json, so latest was the only alias that mis-compared — and being the default, it fired for essentially every visitor. That noise also defeats the check's purpose: the genuine mismatch it exists to catch (WordPress restored from browser storage at a different version) looked identical to the false positive.

Implementation details

Resolve latest to LatestMinifiedWordPressVersion at the same place nightly is already resolved to trunk, in PlaygroundWorkerEndpointBlueprints.boot().

The download path is unchanged. Previously latest failed the MinifiedWordPressVersionsList.includes() check and fell through to LatestMinifiedWordPressVersion; now it passes that check and yields the same value. It still can't reach the wordpress.org branch, which requires !isMinifiedVersion. The now-stale comment describing latest as falling through is updated.

This also improves getWordPressModuleDetails(), whose majorVersion fallback could previously report latest instead of a version.

Fixing it here rather than at the caller keeps ?wp=latest working as the documented public value — the alias just stops leaking past the boot boundary.

Testing Instructions (or ideally a Blueprint)

  1. npm run dev, open http://127.0.0.1:5400/website-server/ with the console open, and wait for boot — no version-mismatch warning (there is one on trunk).
  2. Load ?wp=nightly and ?wp=6.9 — still no warning, correct build boots.
  3. npx nx test playground-remote --testFile=playground-worker-endpoint-blueprints.spec.ts

Added a parameterized test asserting requestedWordPressVersion holds a build version for latest, nightly, and an explicit 6.8. Verified it fails on trunk (expected 'latest' to be '7.0') and passes with the fix.

Copilot AI lite review requested due to automatic review settings August 5, 2026 05:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Resolves the latest WordPress alias to a concrete build version during worker boot so version comparisons use consistent build-version strings and avoid false mismatch warnings.

Changes:

  • Normalize latest (and keep nightly) to a concrete minified build version in boot().
  • Update an in-code comment to reflect the new alias-resolution behavior.
  • Add a parameterized Vitest case asserting alias-to-build resolution for latest, nightly, and explicit versions.

Reviewed changes

Copilot reviewed 2 out of 8 changed files in this pull request and generated 1 comment.

File Description
packages/playground/remote/src/lib/playground-worker-endpoint-blueprints.ts Resolves latest/nightly early so later logic compares build versions rather than aliases.
packages/playground/remote/src/lib/playground-worker-endpoint-blueprints.spec.ts Adds a parameterized test to assert requestedWordPressVersion is normalized to a build version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +356 to +383
it.each([
{ wpVersion: 'latest', expected: LatestMinifiedWordPressVersion },
{ wpVersion: 'nightly', expected: 'trunk' },
{ wpVersion: '6.8', expected: '6.8' },
])(
'resolves the requested WordPress version $wpVersion to a build version',
async ({ wpVersion, expected }) => {
let endpoint:
| {
boot(options: Record<string, unknown>): Promise<void>;
requestedWordPressVersion?: string;
}
| undefined;
vi.doMock('@wp-playground/wordpress', () => ({
bootWordPress: vi.fn(),
}));
vi.doMock('@php-wasm/web', () => ({
certificateToPEM: vi.fn(),
createDirectoryHandleMountHandler: vi.fn(),
exposeAPI: vi.fn((api) => {
endpoint = api;
return [vi.fn(), vi.fn()];
}),
loadWebRuntime: vi.fn(),
}));
await import('./playground-worker-endpoint-blueprints');
if (!endpoint) {
throw new Error('Expected exposeAPI to receive an endpoint');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vi.resetModules() already runs in the describe-level beforeEach (line 7), which Vitest applies before every case, it.each rows included. beforeEach also stubs a fresh self, so the once-per-global guard flag is cleared too — both conditions for re-evaluating the entrypoint are met per case.

The last test in this file demonstrates it: it imports the entrypoint, calls vi.resetModules(), imports again, and asserts the guard throws. That only happens if the module body re-runs, so the module isn't served from cache after a reset. The existing 4-row handles a concrete WordPress release ... it.each uses the same doMock + dynamic-import pattern.

Verified all three rows pass in isolation, and each has an explicit if (!endpoint) throw guard, so the failure mode described here couldn't pass silently.

On cleanup: afterEach already doUnmocks @php-wasm/web, @wp-playground/blueprints and @wp-playground/wordpress, plus vi.unstubAllGlobals().

`requestedWordPressVersion` stored the `latest` alias verbatim while the
loaded-version check compared it against a resolved build version, so every
default boot warned about a mismatch that did not exist.

Resolve `latest` to LatestMinifiedWordPressVersion at the same place `nightly`
is already resolved to `trunk`.
@amitraj2203
amitraj2203 force-pushed the fix/resolve-latest-wp-version-alias branch from 32696db to b89fdf8 Compare August 5, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spurious "Loaded WordPress version differs from requested version" warning on every default boot

2 participants