CLI: Fix --login option and "landingPage" Blueprint property #2344
+43
−12
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.
Makes the --login flag work in Playground CLI.
When you start the CLI server for the second time on the same machine it shows the login screen instead of auto-logging you in. The culprit is the
playground_auto_login_already_happened
cookie, which the first run sets and later runs inherit. Because the cookie survives process restarts, the auto-login plugin silently skips its job. Solution
run-cli.ts now tracks whether a request is the very first one served by the process. On that first hit it:
• clears the stale cookie by returning a Set-Cookie header that expires it immediately, and
• responds with a 302 pointing to /, guaranteeing the request that follows will hit WordPress after the login routine runs.
The logic is guarded by a boolean isFirstRequest flag initialised at boot and flipped after the first response.
As a follow up, we'll need to also adjust how the landingPage property is handled (it collides with the hardcoded redirection to /)
CI adjustments
Because the very first HTTP call now yields a redirect, the workflow had to be taught to trigger—and then ignore—the 301/302 chain. The fix:
• primes the server with an initial curl so the redirect is consumed before the readiness probe starts
• replaces the Playground-CLI-based package host with a Python http.server to avoid using tool that's being tested in the test
How to verify
Run wp-playground server twice in a row. Each session should open directly in wp-admin without showing the login form. The CI matrix stays green.