[php-src] PR #15459: Fix registration of internal readonly child classes
| From: | kocsismate | Date: | Sat, 17 Aug 2024 11:59:08 +0000 |
| Subject: | [php-src] PR #15459: Fix registration of internal readonly child classes | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-28015@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/15459
Author: kocsismate
Currently, internal classes are registered with the following code:
```
INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;
```
This worked well so far, except if
InternalClass is a readonly class. It is because
some inheritance checks are run by zend_register_internal_class_ex, before
ZEND_ACC_READONLY_CLASS is added to ce_flags.
The issue is fixed by adding a zend_register_internal_class_with_flags() zend API
function that stubs can use from now on. This function makes sure to add the flags before running
any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep
support for the existing API for PHP 8.4-.