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_ast.c b/Zend/zend_ast.c index cd8e6792d031..764cac3f12af 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1247,6 +1247,12 @@ static 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/Zend/zend_compile.c b/Zend/zend_compile.c index 1ce921d4fec2..fb04387a0045 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -12564,6 +12564,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]))) { diff --git a/build/gen_stub.php b/build/gen_stub.php index 9cd9b9a18768..2670e85458db 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; 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 */ 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