[php-src] PR #13976: Fix GH-13970: Incorrect validation of #[\Attribute]’s first parameter
| From: | nielsdos | Date: | Mon, 15 Apr 2024 20:13:01 +0000 |
| Subject: | [php-src] PR #13976: Fix GH-13970: Incorrect validation of #[\Attribute]’s first parameter | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-25769@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/13976
Author: nielsdos
In c1959e63e5 code was added to deal with preloading of enums, which had to be special cased because
they are object instances. In 4397811db2 this code was changed because array instances can contain
object instances due to enums. In that commit, the code started using zval_update_constant_ex() and
stopped ZEND_AST_CONST_ENUM_INIT resolution when in compilation.
Since the attribute in the testcase is resolved during compilation, the resolution fails as well,
even though in this case we can resolve it fine as the problem is only with persisting constants
during preloading.
This patch restores the original code but changes the IS_OBJECT condition to Z_COLLECTABLE such that
both arrays and objects that are resolved from IS_CONSTANT_AST are not persisted to shm.
I don't know for sure if this is the best approach. An alternative I thought of is looping
through the array to see if it contains objects but that seems more complicated and I'm not
sure that's better.