Skip to content

Add PHP 5.6 WebAssembly build support for legacy WordPress versions#3284

Closed
adamziel wants to merge 1 commit intoWordPress:trunkfrom
articles-adamziel-com:support/legacy-php-versions
Closed

Add PHP 5.6 WebAssembly build support for legacy WordPress versions#3284
adamziel wants to merge 1 commit intoWordPress:trunkfrom
articles-adamziel-com:support/legacy-php-versions

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

Summary

  • Add build system support for compiling PHP 5.6 to WebAssembly, enabling WordPress Playground to run WordPress 1.x through 4.x
  • PHP 5.6 is backward compatible with PHP 5.2 code, so a single legacy version covers all older WordPress releases that require PHP 5.2+
  • Modify the Dockerfile and C source extensions with PHP 5.x version guards and compatibility stubs
  • Add dedicated legacy PHP test suite (separate from the main PHP 7.4-8.5 test matrix)

Changes

Build system (Dockerfile + C sources):

  • Add PHP 5.x version guards for fiber-asm, imagick, chunk-alloc patches, ASM arithmetic, cli_server
  • Port proc_open, dns_polyfill, post_message_to_js, and wasm_memory_storage extensions for PHP 5.x compatibility
  • Create php5.6.patch for Emscripten-specific fixes
  • Make apply-mysqlnd-patch.sh tolerant of PHP 5.x (different API)

Package scaffolding:

  • packages/php-wasm/node-builds/5-6/ and web-builds/5-6/ with full NX project configuration
  • Add case '5.6' to node and web getPHPLoaderModule() loader modules
  • Add LegacyPHPVersions export (separate from SupportedPHPVersions to avoid test regressions)
  • Add tsconfig.base.json path aliases for new packages

Test suite:

  • legacy-php-versions.spec.ts with 12 tests covering: version verification, execution, file I/O, networking, proc_open, SQLite, JSON, sessions, mbstring, error handling, memory, and filesystem
  • Completely separate from the main test matrix — runs independently

Next step: compile WASM binaries

The 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
node packages/php-wasm/compile/build.js --PLATFORM=web --PHP_VERSION=5.6 --WITH_IMAGICK=no --WITH_OPCACHE=no

Test plan

  • Existing PHP 7.4-8.5 tests pass (769 passed, 1 pre-existing flaky timing test)
  • TypeScript typecheck passes for php-wasm-universal and php-wasm-node
  • Lint passes for php-wasm-node
  • NX recognizes new php-wasm-node-5-6 and php-wasm-web-5-6 projects
  • Compile PHP 5.6 WASM binaries (requires Docker)
  • Run legacy test suite against compiled binaries
  • Test WordPress 4.x, 3.x, 2.x, 1.x on PHP 5.6

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 18, 2026 13:43
@adamziel adamziel requested a review from a team as a code owner February 18, 2026 13:43
@adamziel adamziel requested a review from akirk February 18, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds build system support for compiling PHP 5.6 to WebAssembly, enabling WordPress Playground to run legacy WordPress versions (1.x through 4.x) that require PHP 5.2+. PHP 5.6 is backward compatible with PHP 5.2 code, providing a single legacy binary for all older WordPress releases.

Changes:

  • Added PHP 5.x version guards and compatibility stubs to C extensions (proc_open, dns_polyfill, post_message_to_js, wasm_memory_storage)
  • Created NX project scaffolding for @php-wasm/node-5-6 and @php-wasm/web-5-6 packages
  • Added separate legacy PHP test suite with 12 tests covering core functionality

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsconfig.base.json Added TypeScript path aliases for PHP 5.6 node and web packages
packages/php-wasm/web/src/lib/get-php-loader-module.ts Added case '5.6' to web loader module switch
packages/php-wasm/node/src/lib/get-php-loader-module.ts Added case '5.6' to node loader module switch
packages/php-wasm/universal/src/lib/supported-php-versions.ts Added LegacyPHPVersions export and type
packages/php-wasm/universal/src/lib/index.ts Exported LegacyPHPVersions and LegacyPHPVersion type
packages/php-wasm/supported-php-versions.mjs Added PHP 5.6 entry to phpVersions array
packages/php-wasm/node/src/test/legacy-php-versions.spec.ts Created comprehensive test suite for legacy PHP versions
packages/php-wasm/web-builds/5-6/* Created complete package structure for web PHP 5.6 build
packages/php-wasm/node-builds/5-6/* Created complete package structure for node PHP 5.6 build
packages/php-wasm/compile/php/proc_open.* Added PHP 5.x stub implementation for proc_open functions
packages/php-wasm/compile/php/php5.6.patch Added PHP 5.6-specific patch for empty file copy issue
packages/php-wasm/compile/php/apply-mysqlnd-patch.sh Made script tolerant of missing mysqlnd in PHP 5.x
packages/php-wasm/compile/php/Dockerfile Added version guards for fiber-asm, imagick, chunk-alloc, asm arithmetic, and cli_server
packages/php-wasm/compile/php-wasm-memory-storage/wasm_memory_storage.c Added PHP 5.x no-op implementation
packages/php-wasm/compile/php-wasm-dns-polyfill/dns_polyfill.c Added PHP 5.x compatibility with TSRMLS_CC and type adjustments
packages/php-wasm/compile/php-post-message-to-js/post_message_to_js.c Added PHP 5.x compatibility for string return handling

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

@adamziel adamziel force-pushed the support/legacy-php-versions branch from 93e68b1 to 309db6e Compare February 18, 2026 14:11
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>
@mho22
Copy link
Copy Markdown
Collaborator

mho22 commented Apr 15, 2026

@JanJakes Do you think we can close this pull request now that you implemented 5.2 ?

@JanJakes
Copy link
Copy Markdown
Member

@mho22 Yes, I missed this one. Thanks for noticing! Closing in favor of #3490.

@JanJakes JanJakes closed this Apr 15, 2026
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.

5 participants