Skip to content

[PHP] Support PHP 8.5 #2473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"recompile:php:web:asyncify:7.2": "nx recompile-php:asyncify php-wasm-web -- --PHP_VERSION=7.2 ",
"recompile:php:node": "nx recompile-php:all php-wasm-node ",
"recompile:php:node:jspi:all": "nx recompile-php:jspi:all php-wasm-node ",
"recompile:php:node:jspi:8.5": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=8.5 ",
"recompile:php:node:jspi:8.4": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=8.4 ",
"recompile:php:node:jspi:8.3": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=8.3 ",
"recompile:php:node:jspi:8.2": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=8.2 ",
Expand All @@ -54,6 +55,7 @@
"recompile:php:node:jspi:7.3": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=7.3 ",
"recompile:php:node:jspi:7.2": "nx recompile-php:jspi php-wasm-node -- --PHP_VERSION=7.2 ",
"recompile:php:node:asyncify:all": "nx recompile-php:asyncify:all php-wasm-node ",
"recompile:php:node:asyncify:8.5": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=8.5 ",
"recompile:php:node:asyncify:8.4": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=8.4 ",
"recompile:php:node:asyncify:8.3": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=8.3 ",
"recompile:php:node:asyncify:8.2": "nx recompile-php:asyncify php-wasm-node -- --PHP_VERSION=8.2 ",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/site/docs/blueprints/03-data-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The `landingPage` property tells Playground which URL to navigate to after the B

The `preferredVersions` property declares your preferred PHP and WordPress versions. It can contain the following properties:

- `php` (string): Loads the specified PHP version. Accepts `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, or `latest`. Minor versions like `7.4.1` are not supported.
- `php` (string): Loads the specified PHP version. Accepts `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`, or `latest`. Minor versions like `7.4.1` are not supported.
- `wp` (string): Loads the specified WordPress version. Accepts the last four major WordPress versions. As of June 1, 2024, that's `6.2`, `6.3`, `6.4`, or `6.5`. You can also use the generic values `latest`, `nightly`, or `beta`. To use a pre-release version of WordPress, `beta` will load the latest beta or release candidate versions of a release cycle (Beta or RC).

```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ The `landingPage` property tells Playground which URL to navigate to after the B
The `preferredVersions` property declares your preferred PHP and WordPress versions. It can contain the following properties:
-->

- `php` (文字列): 指定された PHP バージョンを読み込みます。`7.0`、`7.1`、`7.2`、`7.3`、`7.4`、`8.0`、`8.1`、`8.2`、`8.3`、`8.4`、`latest` が使用できます。`7.4.1` などのマイナーバージョンはサポートされていません。
- `php` (文字列): 指定された PHP バージョンを読み込みます。`7.0`、`7.1`、`7.2`、`7.3`、`7.4`、`8.0`、`8.1`、`8.2`、`8.3`、`8.4`、`8.5`、`latest` が使用できます。`7.4.1` などのマイナーバージョンはサポートされていません。
- `wp` (文字列): 指定された WordPress バージョンを読み込みます。最新の 4 つのメジャー WordPress バージョンが使用できます。2024 年 6 月 1 日時点では、`6.2`、`6.3`、`6.4`、`6.5` が使用できます。汎用値として `latest`、`nightly`、`beta` も使用できます。WordPress のプレリリース版を使用する場合、`beta` はリリースサイクルの最新のベータ版またはリリース候補版 (ベータ版または RC 版) を読み込みます。

<!--
- `php` (string): Loads the specified PHP version. Accepts `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, or `latest`. Minor versions like `7.4.1` are not supported.
- `php` (string): Loads the specified PHP version. Accepts `7.0`, `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4`, `8.5`, or `latest`. Minor versions like `7.4.1` are not supported.
- `wp` (string): Loads the specified WordPress version. Accepts the last four major WordPress versions. As of June 1, 2024, that's `6.2`, `6.3`, `6.4`, or `6.5`. You can also use the generic values `latest`, `nightly`, or `beta`. To use a pre-release version of WordPress, `beta` will load the latest beta or release candidate versions of a release cycle (Beta or RC).
-->

Expand Down
2 changes: 1 addition & 1 deletion packages/php-wasm/compile/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ARG WITH_OPCACHE

# Clone PHP
RUN git clone https://github.com/php/php-src.git php-src \
--branch PHP-$PHP_VERSION \
--tag php-$PHP_VERSION \
--single-branch \
--depth 1;

Expand Down
39 changes: 39 additions & 0 deletions packages/php-wasm/compile/php/php8.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/php-src/ext/opcache/zend_accelerator_debug.c b/php-src/ext/opcache/zend_accelerator_debug.c
index b2a3105dc62..f7e328312a8 100644
--- a/php-src/ext/opcache/zend_accelerator_debug.c
+++ b/php-src/ext/opcache/zend_accelerator_debug.c
@@ -25,6 +25,9 @@
#include <time.h>
#ifdef ZEND_WIN32
# include <process.h>
+#else
+/* Error: call to undeclared function 'getpid' */
+# include <unistd.h>
#endif
#include "ZendAccelerator.h"

diff --git a/php-src/ext/standard/file.c b/php-src/ext/standard/file.c
index 01f49640e4a..e559b61b0c6 100644
--- a/php-src/ext/standard/file.c
+++ b/php-src/ext/standard/file.c
@@ -1507,6 +1507,20 @@ PHPAPI zend_result php_copy_file_ctx(const char *src, const char *dest, int src_
goto safe_to_copy;
break;
case 0:
+ // Fix for https://github.com/WordPress/wordpress-playground/issues/54:
+ // Problem: Calling copy() on an empty source file crashes the JavaScript
+ // runtime.
+ // Solution: Avoid copying empty files. Just create create an empty
+ // destination file and return.
+ if (src_s.sb.st_size == 0) {
+ zend_string *opened_path = zend_string_init("", strlen(""), 0);
+ php_stream *stream = php_stream_open_wrapper(dest, "w", REPORT_ERRORS, &opened_path);
+ if (stream) {
+ php_stream_close(stream);
+ return SUCCESS;
+ }
+ return FAILURE;
+ }
break;
default: /* failed to stat file, does not exist? */
return ret;
2 changes: 2 additions & 0 deletions packages/php-wasm/compile/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"nx run php-wasm-compile:xdebug:asyncify --PHP_VERSION=8.5",
"nx run php-wasm-compile:xdebug:asyncify --PHP_VERSION=8.4",
"nx run php-wasm-compile:xdebug:asyncify --PHP_VERSION=8.3",
"nx run php-wasm-compile:xdebug:asyncify --PHP_VERSION=8.2",
Expand All @@ -47,6 +48,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"nx run php-wasm-compile:xdebug:jspi --PHP_VERSION=8.5",
"nx run php-wasm-compile:xdebug:jspi --PHP_VERSION=8.4",
"nx run php-wasm-compile:xdebug:jspi --PHP_VERSION=8.3",
"nx run php-wasm-compile:xdebug:jspi --PHP_VERSION=8.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/php-wasm/compile/update-php-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function fetchFromGitHub() {
for (const tag of data) {
const tagName = tag.name;
// Match patterns like "php-8.3.15", "php-8.2.26", etc.
const match = tagName.match(/^php-(\d+)\.(\d+)\.(\d+)$/);
const match = tagName.match(/^php-(\d+)\.(\d+)\.(\d+)(?:alpha\d+)?$/);
if (match) {
const [, major, minor, patch] = match;
const version = `${major}.${minor}`;
Expand Down
6 changes: 6 additions & 0 deletions packages/php-wasm/node/src/lib/get-php-loader-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export async function getPHPLoaderModule(
): Promise<PHPLoaderModule> {
if (await jspi()) {
switch (version) {
case '8.5':
// @ts-ignore
return await import(`../../jspi/php_8_5.js`);
case '8.4':
// @ts-ignore
return await import(`../../jspi/php_8_4.js`);
Expand Down Expand Up @@ -34,6 +37,9 @@ export async function getPHPLoaderModule(
}
} else {
switch (version) {
case '8.5':
// @ts-ignore
return await import(`../../asyncify/php_8_5.js`);
case '8.4':
// @ts-ignore
return await import(`../../asyncify/php_8_4.js`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export async function getXdebugExtensionModule(
*/
if (await jspi()) {
switch (version) {
case '8.5':
return (
await import(
// @ts-ignore
`../../../jspi/extensions/xdebug/8_5/xdebug.so?url`
)
).default;
case '8.4':
return (
await import(
Expand Down Expand Up @@ -77,6 +84,13 @@ export async function getXdebugExtensionModule(
}
} else {
switch (version) {
case '8.5':
return (
await import(
// @ts-ignore
`../../../asyncify/extensions/xdebug/8_5/xdebug.so?url`
)
).default;
case '8.4':
return (
await import(
Expand Down
8 changes: 7 additions & 1 deletion packages/php-wasm/supported-php-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
* @property {string} lastRelease
*/

export const lastRefreshed = '2025-08-04T12:45:56.385Z';
export const lastRefreshed = '2025-08-07T12:09:02.133Z';

/**
* @type {PhpVersion[]}
* @see https://www.php.net/releases/index.php
*/
export const phpVersions = [
{
version: '8.5',
loaderFilename: 'php_8_5.js',
wasmFilename: 'php_8_5.wasm',
lastRelease: '8.5.0alpha4',
},
{
version: '8.4',
loaderFilename: 'php_8_4.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const SupportedPHPVersions = [
'8.5',
'8.4',
'8.3',
'8.2',
Expand Down
6 changes: 6 additions & 0 deletions packages/php-wasm/web/src/lib/get-php-loader-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export async function getPHPLoaderModule(
): Promise<PHPLoaderModule> {
if (await jspi()) {
switch (version) {
case '8.5':
// @ts-ignore
return await import('../../public/php/jspi/php_8_5.js');
case '8.4':
// @ts-ignore
return await import('../../public/php/jspi/php_8_4.js');
Expand Down Expand Up @@ -41,6 +44,9 @@ export async function getPHPLoaderModule(
}
} else {
switch (version) {
case '8.5':
// @ts-ignore
return await import('../../public/php/asyncify/php_8_5.js');
case '8.4':
// @ts-ignore
return await import('../../public/php/asyncify/php_8_4.js');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ const schema11 = {
},
SupportedPHPVersion: {
type: 'string',
enum: ['8.4', '8.3', '8.2', '8.1', '8.0', '7.4', '7.3', '7.2'],
enum: [
'8.5',
'8.4',
'8.3',
'8.2',
'8.1',
'8.0',
'7.4',
'7.3',
'7.2',
],
},
ExtraLibrary: { type: 'string', const: 'wp-cli' },
PHPConstants: {
Expand Down
12 changes: 11 additions & 1 deletion packages/playground/blueprints/public/blueprint-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,17 @@
},
"SupportedPHPVersion": {
"type": "string",
"enum": ["8.4", "8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2"]
"enum": [
"8.5",
"8.4",
"8.3",
"8.2",
"8.1",
"8.0",
"7.4",
"7.3",
"7.2"
]
},
"ExtraLibrary": {
"type": "string",
Expand Down
Loading