Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Destroy temporary module classes in reverse order
This commit is contained in:
Arnaud Le Blanc 2025-03-14 10:48:27 +01:00
commit 4b9c72f329
No known key found for this signature in database
GPG key ID: 0098C05DD15ABC13
5 changed files with 84 additions and 14 deletions

View file

@ -22,6 +22,7 @@
#include "zend.h"
#include "zend_execute.h"
#include "zend_API.h"
#include "zend_hash.h"
#include "zend_modules.h"
#include "zend_extensions.h"
#include "zend_constants.h"
@ -3263,21 +3264,17 @@ ZEND_API zend_result zend_get_module_started(const char *module_name) /* {{{ */
}
/* }}} */
static int clean_module_class(zval *el, void *arg) /* {{{ */
{
zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
int module_number = *(int *)arg;
if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
return ZEND_HASH_APPLY_REMOVE;
} else {
return ZEND_HASH_APPLY_KEEP;
}
}
/* }}} */
static void clean_module_classes(int module_number) /* {{{ */
{
zend_hash_apply_with_argument(EG(class_table), clean_module_class, (void *) &module_number);
/* Child classes may reuse structures from parent classes, so destroy in reverse order. */
Bucket *bucket;
ZEND_HASH_REVERSE_FOREACH_BUCKET(EG(class_table), bucket) {
zend_class_entry *ce = Z_CE(bucket->val);
if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) {
zend_hash_del_bucket(EG(class_table), bucket);
}
} ZEND_HASH_FOREACH_END();
}
/* }}} */