fix(playground): propagate phpEnv into PHP.run and request workers - #2505
Open
chubes4 wants to merge 3 commits into
Open
fix(playground): propagate phpEnv into PHP.run and request workers#2505chubes4 wants to merge 3 commits into
chubes4 wants to merge 3 commits into
Conversation
External-database credentials were passed to Playground CLI as phpEnv but never applied to PHP.run env or isolated request-worker payloads, so getenv() saw an empty password.
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.
Summary
External-database connector secrets were passed to Playground CLI as
phpEnv(mapped to EmscriptenENV) but never applied to the PHP APIs that actually populategetenv().PHP-WASM applies environment per run via
PHP.run({ env })→wasm_add_ENV_entry. Isolated executions withprocessIdentitygo through request workers andputenv()only the payload environment. Both paths droppedphpEnv:shouldUseProgrammaticPlaygroundRunnerforces the CLI/backendPackagepath fordatabaseSetup: "external"and whenever acliModuleis provided.secretEnvPhpstrips connector secrets from generated command PHP (so they are not serialized).playground.run()was called with{ code }only.spec.environmentonly.WordPress then defined
DB_PASSWORDfromgetenv('DB_PASSWORD')(empty) and mysqli failed with access denied.This change injects
runtimePhpEnvironment()into everyplayground.run()and into request-worker payloads. Secrets stay out of PHP source and auto-prepend files.The PHP 8.4 overlay remains the deliberate 3.1.53 floor (ABI exports from WordPress/wordpress-playground#4108). The Playground driver stays on 3.1.46 so the 8.3 overlay and CLI patch still dedupe; #4146 is still open, so overlay carry is not dropped.
Tests
runOptions.envinstead ofrunCLI.phpEnv(that previous mock hid the hole).tests/playground-cli-php-env-propagation.test.tscovers isolated request-worker payload injection.npm run checkpassed.AI assistance: GPT-6 Astra via OpenCode diagnosed the blocker chain; Grok 4.6 via
opencode runimplemented the fix and ran the suites.