[php-src] PHP-8.6: ext/simplexml: Resolve constants of user classes before instantiation
| From: | Ilia Alshanetsky | Date: | Thu, 19 Nov 2026 23:16:02 +0000 |
| Subject: | [php-src] PHP-8.6: ext/simplexml: Resolve constants of user classes before instantiation | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143933@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-11-19T18:07:09-05:00
Commit: https://github.com/php/php-src/commit/4fd9867c60499ca3eab0394fb6d095f620be6109
Raw diff: https://github.com/php/php-src/commit/4fd9867c60499ca3eab0394fb6d095f620be6109.diff
ext/simplexml: Resolve constants of user classes before instantiation
simplexml_load_string(), simplexml_load_file() and simplexml_import_dom()
create the object for a class_name class through php_sxe_object_new() and
so skip the zend_update_class_constants() call that object_init_ex() makes.
The constants of such a class (class constants, static and default property
values) are not resolved first: a default property is copied into the
object as a constant AST, an undefined constant or a type mismatch goes
unreported, and under opcache the immutable class has no mutable data yet,
so object_properties_init() dereferences NULL. Resolve the constants before
any XML is parsed or imported, as new does before calling the constructor.
In simplexml_import_dom() this has to precede php_libxml_import_node(), as
constant evaluation can run an autoloader that reloads the document and
frees the node. GH-25585 is the SPL counterpart.
Closes GH-25598
Changed paths:
A ext/simplexml/tests/simplexml_load_class_constants.phpt
M NEWS
M ext/simplexml/simplexml.c
Diff: