From 23f4b935236e0b811e85f2c8876c04a538ce0c0c Mon Sep 17 00:00:00 2001 From: Giovanni Giacobbi Date: Thu, 29 Jan 2026 11:58:12 +0100 Subject: [PATCH 1/5] gen_stub: Fix compatibility with php 7.4 (in PHP-8.4) (#21076) --- build/gen_stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 58b846d2cb54..28b168c72642 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -84,7 +84,7 @@ function processStubFile(string $stubFile, Context $context, bool $includeOnly = } /* Because exit() and die() are proper token/keywords we need to hack-around */ - $hasSpecialExitAsFunctionHandling = str_ends_with($stubFile, 'zend_builtin_functions.stub.php'); + $hasSpecialExitAsFunctionHandling = basename($stubFile) == 'zend_builtin_functions.stub.php'; if (!$fileInfo = $context->parsedFiles[$stubFile] ?? null) { initPhpParser(); $stubContent = $stubCode ?? file_get_contents($stubFile); From 7ec14e3ca412db12e317258e805340fee13dba1d Mon Sep 17 00:00:00 2001 From: Giovanni Giacobbi Date: Thu, 29 Jan 2026 12:01:01 +0100 Subject: [PATCH 2/5] gen_stub: Fix compatibility with php 7.4 (in PHP-8.5+) (#21075) --- build/gen_stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 4a293972f04c..57424ac33aa9 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2235,7 +2235,7 @@ public function __clone() class EvaluatedValue { - public /* readonly */ mixed $value; + public /* readonly */ /* mixed */ $value; public SimpleType $type; public Expr $expr; public bool $isUnknownConstValue; From 2f2b421a485b9b95265b591d90aaabea90d35ec9 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 29 Jan 2026 00:25:14 +0100 Subject: [PATCH 3/5] Fix segfault when preloading constant AST closure Fixes GH-21059 Closes GH-21071 --- NEWS | 1 + Zend/zend_ast.c | 6 ++++++ ext/opcache/tests/preload_gh21059.inc | 7 +++++++ ext/opcache/tests/preload_gh21059.phpt | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 ext/opcache/tests/preload_gh21059.inc create mode 100644 ext/opcache/tests/preload_gh21059.phpt diff --git a/NEWS b/NEWS index dbf94f748827..8ec869035f0d 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ PHP NEWS - Core: . Fixed bug GH-21029 (zend_mm_heap corrupted on Aarch64, LTO builds). (Arnaud) + . Fixed bug GH-21059 (Segfault when preloading constant AST closure). (ilutov) - Windows: . Fixed compilation with clang (missing intrin.h include). (Kévin Dunglas) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 9cb3c7aae4a1..62a4bfec5062 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1154,6 +1154,12 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( } case ZEND_AST_OP_ARRAY: { + // Preloading will attempt to resolve constants but objects can't be stored in shm + // Aborting here to store the const AST instead + if (CG(in_compilation)) { + return FAILURE; + } + zend_function *func = (zend_function *)zend_ast_get_op_array(ast)->op_array; zend_create_closure(result, func, scope, scope, NULL); diff --git a/ext/opcache/tests/preload_gh21059.inc b/ext/opcache/tests/preload_gh21059.inc new file mode 100644 index 000000000000..8f93bb45020b --- /dev/null +++ b/ext/opcache/tests/preload_gh21059.inc @@ -0,0 +1,7 @@ + +--FILE-- + +--EXPECT-- +Hello world From e9ae04062986023be41798f6a31b3acfcd0a49a2 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Thu, 29 Jan 2026 13:51:53 +0530 Subject: [PATCH 4/5] Fix crash on (unset) cast in constant expression Fixes GH-21072 Closes GH-21073 --- NEWS | 2 ++ Zend/tests/ast/gh21072.phpt | 17 +++++++++++++++++ Zend/zend_compile.c | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 Zend/tests/ast/gh21072.phpt diff --git a/NEWS b/NEWS index 8ec869035f0d..07c66ec833e0 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - Core: . Fixed bug GH-21029 (zend_mm_heap corrupted on Aarch64, LTO builds). (Arnaud) . Fixed bug GH-21059 (Segfault when preloading constant AST closure). (ilutov) + . Fixed bug GH-21072 (Crash on (unset) cast in constant expression). + (arshidkv12) - Windows: . Fixed compilation with clang (missing intrin.h include). (Kévin Dunglas) diff --git a/Zend/tests/ast/gh21072.phpt b/Zend/tests/ast/gh21072.phpt new file mode 100644 index 000000000000..1ffd0518eaea --- /dev/null +++ b/Zend/tests/ast/gh21072.phpt @@ -0,0 +1,17 @@ +--TEST-- +(unset) cast must not be allowed in constant expressions +--CREDITS-- +Viet Hoang Luu (@vi3tL0u1s) +--FILE-- +getMessage(); +} +?> +--EXPECTF-- +Fatal error: The (unset) cast is no longer supported in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8be1ee14f485..80f85f421a33 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -12360,6 +12360,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ zend_eval_const_expr(&ast->child[1]); return; case ZEND_AST_CAST: + if (ast->attr == IS_NULL) { + zend_error_noreturn(E_COMPILE_ERROR, "The (unset) cast is no longer supported"); + } zend_eval_const_expr(&ast->child[0]); if (ast->child[0]->kind == ZEND_AST_ZVAL && zend_try_ct_eval_cast(&result, ast->attr, zend_ast_get_zval(ast->child[0]))) { From 5ce36453d66143548485cb57fb19bf4157ab60c2 Mon Sep 17 00:00:00 2001 From: Arshid Date: Thu, 29 Jan 2026 21:49:14 +0530 Subject: [PATCH 5/5] [skip ci] Use STANDARD_MODULE_HEADER for ext-date (GH-21080) --- ext/date/php_date.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 8f98589b2b47..e462b70d2cff 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -370,9 +370,7 @@ static int date_object_compare_timezone(zval *tz1, zval *tz2); /* {{{ Module struct */ zend_module_entry date_module_entry = { - STANDARD_MODULE_HEADER_EX, - NULL, - NULL, + STANDARD_MODULE_HEADER, "date", /* extension name */ ext_functions, /* function list */ PHP_MINIT(date), /* process startup */