[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Mon, 19 Oct 2026 20:44:54 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142476@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-19T22:44:20+02:00 Commit: https://github.com/php/php-src/commit/bbed764507c38fe3cc60a4609c709504aa88434f Raw diff: https://github.com/php/php-src/commit/bbed764507c38fe3cc60a4609c709504aa88434f.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/standard: Don't share the unserialize() context with enum autoloaders Changed paths: A Zend/tests/enum/unserialize-autoload-nested.phpt M NEWS M ext/standard/var_unserializer.re Diff: diff --git a/NEWS b/NEWS index e77ada9c2a0d..714bb44ebb9b 100644 --- a/NEWS +++ b/NEWS @@ -98,6 +98,8 @@ PHP NEWS bcrypt costs. (Ilia Alshanetsky) . Fixed proc_open() null descriptor not being inheritable on Windows. (Jorg Sowa) + . Don't share the unserialize() context with enum autoloaders. + (Nicolas Grekas) - Tidy: . Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and diff --git a/Zend/tests/enum/unserialize-autoload-nested.phpt b/Zend/tests/enum/unserialize-autoload-nested.phpt new file mode 100644 index 000000000000..296f7af31415 --- /dev/null +++ b/Zend/tests/enum/unserialize-autoload-nested.phpt @@ -0,0 +1,36 @@ +--TEST-- +Enum unserialize runs the autoloader outside of the current unserialize() context +--FILE-- +<?php + +class Init { + public bool $ready = false; + + public function __unserialize(array $data): void { + $this->ready = true; + } +} + +enum Backed: string { + case Foo = Value::FOO; +} + +spl_autoload_register(function ($class) { + var_dump(unserialize('O:4:"Init":0:{}')->ready); + eval(match ($class) { + 'Pure' => 'enum Pure { case Foo; }', + 'Value' => 'class Value { const FOO = "foo"; }', + }); +}); + +foreach (['E:8:"Pure:Foo";', 'E:10:"Backed:Foo";'] as $enum) { + $data = unserialize('a:3:{i:0;' . $enum . 'i:1;O:8:"stdClass":0:{}i:2;r:3;}'); + var_dump($data[1] === $data[2]); +} + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 353c7086d430..aedc2518eb3f 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -1384,7 +1384,9 @@ object ":" uiv ":" ["] { goto fail; } + BG(serialize_lock)++; zend_class_entry *ce = zend_lookup_class(enum_name); + BG(serialize_lock)--; if (!ce) { php_error_docref(NULL, E_WARNING, "Class '%s' not found", ZSTR_VAL(enum_name)); goto fail; @@ -1413,7 +1415,10 @@ object ":" uiv ":" ["] { zval *value = &c->value; if (Z_TYPE_P(value) == IS_CONSTANT_AST) { - if (zval_update_constant_ex(value, c->ce) == FAILURE) { + BG(serialize_lock)++; + zend_result result = zval_update_constant_ex(value, c->ce); + BG(serialize_lock)--; + if (result == FAILURE) { return 0; } }

« previous php.cvs (#142476) next »