Run legacy WordPress versions on PHP 5.6 compiled to WebAssembly#3386
Draft
wp-playground-bot wants to merge 3 commits intoWordPress:trunkfrom
Draft
Run legacy WordPress versions on PHP 5.6 compiled to WebAssembly#3386wp-playground-bot wants to merge 3 commits intoWordPress:trunkfrom
wp-playground-bot wants to merge 3 commits intoWordPress:trunkfrom
Conversation
Enable compiling PHP 5.6 to WebAssembly so WordPress Playground can run
WordPress 1.x through 4.x, which require PHP 5.2+. PHP 5.6 is backward
compatible with PHP 5.2 code, so a single legacy version covers all older
WordPress releases.
Changes:
- Dockerfile: Add PHP 5.x version guards (fiber-asm, imagick, chunk-alloc
patches, ASM arithmetic, cli_server)
- C sources: Add PHP 5.x compatibility for proc_open, dns_polyfill,
post_message_to_js, and wasm_memory_storage extensions
- Package scaffolding: node-builds/5-6 and web-builds/5-6 with full NX
project configuration
- Loader modules: Add case '5.6' to node and web getPHPLoaderModule()
- Version registry: Add PHP 5.6 to supported-php-versions.mjs and
LegacyPHPVersions in supported-php-versions.ts (separate from
SupportedPHPVersions to avoid test regressions)
- Test suite: Dedicated legacy-php-versions.spec.ts with 12 tests
covering execution, file I/O, networking, proc_open, SQLite, JSON,
sessions, mbstring, error handling, memory, and filesystem ops
- tsconfig.base.json: Path aliases for new packages
Note: WASM binaries must be compiled in a Docker-enabled environment:
node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=5.6 \
--WITH_IMAGICK=no --WITH_OPCACHE=no
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PHP 5.6 is now functional in Playground with both web JSPI and node asyncify variants. This required fixing several compatibility issues between PHP 5.6's C codebase and modern Emscripten/clang: Dockerfile: SQLite duplicate symbol fix for PHP 5.x bundled sqlite3, readdir_r compatibility, x86_64 inline assembly guards, PCRE JIT disable, curl-config shim for PHP 5.x detection, and compiler warning suppression flags (-Wno-implicit-int, -Wno-implicit-function-declaration, -Wno-incompatible-function-pointer-types, etc). php_wasm.c: PHP 5.x API compat for size_t vs int return types in SAPI callbacks, and dup parameter in add_next_index_stringl / RETVAL_STRINGL macros. The test suite's isVersionBuilt() now checks for actual .wasm binary files instead of just directory existence, preventing crashes when placeholder stubs are present but no real binaries exist. Built with limited extensions (no OpenSSL, cURL, GD, ImageMagick, MySQL, mbregex) for this initial release. Verified: PHP boots, initializes SAPI, serves HTTP 200 with X-Powered-By: PHP/5.6.40, and executes PHP code producing correct output.
Resolved three merge conflicts: - packages/php-wasm/supported-php-versions.mjs: Kept PR's newer version numbers and PHP 5.6 entry - packages/php-wasm/node/project.json: Kept both test-legacy-php (PR) and test-file-locking targets (trunk) - packages/php-wasm/node/src/lib/load-runtime.ts: Merged LegacyPHPVersion import with trunk's new imports, kept modernVersion cast with trunk's truthy check
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
WordPress Playground currently supports PHP 7.4 through 8.5, but early WordPress releases (1.x through 4.x) require PHP 5.x. This PR compiles PHP 5.6.40 to WebAssembly and integrates it into the Playground runtime, unlocking the ability to run WordPress all the way back to version 1.0.
PHP 5.6 is backward compatible with PHP 5.2, so a single legacy build covers every older WordPress release that needs PHP 5.x.
What changed
The Dockerfile and C source extensions gained PHP 5.x version guards and compatibility stubs so the existing Emscripten build pipeline can produce PHP 5.6 binaries. Extensions like
proc_open,dns_polyfill,post_message_to_js, andwasm_memory_storagewere ported to work with the older Zend API.New
node-builds/5-6andweb-builds/5-6packages provide the compiled WASM binaries (asyncify and JSPI variants), with the corresponding loader module wiring in both@php-wasm/nodeand@php-wasm/web.A
LegacyPHPVersionsexport keeps the 5.6 version separate from the mainSupportedPHPVersionslist so existing tests and UI aren't affected. A dedicated test suite (legacy-php-versions.spec.ts) covers version verification, file I/O, networking, proc_open, SQLite, JSON, sessions, mbstring, error handling, memory, and filesystem.Supersedes #3284.
Test plan