Commit d2514e39698 for php.net
commit d2514e396980e2a01a92b5d50929ac4dca5f9a9b
Author: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date: Sat May 31 15:59:14 2025 +0200
Simplify SimpleXML code for checking if count() is overridden by a userland class (#18722)
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 37a4ed46b4b..db1d002b669 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -2156,27 +2156,14 @@ static void sxe_object_free_storage(zend_object *object)
/* {{{ php_sxe_find_fptr_count() */
static zend_function* php_sxe_find_fptr_count(zend_class_entry *ce)
{
- zend_function *fptr_count = NULL;
- zend_class_entry *parent = ce;
- int inherited = 0;
-
- while (parent) {
- if (parent == ce_SimpleXMLElement) {
- break;
+ if (ce->type == ZEND_USER_CLASS) {
+ zend_function *fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
+ if (fptr_count->common.scope != ce_SimpleXMLElement) {
+ return fptr_count;
}
- parent = parent->parent;
- inherited = 1;
}
- if (inherited) {
- /* Find count() method */
- fptr_count = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
- if (fptr_count->common.scope == parent) {
- fptr_count = NULL;
- }
- }
-
- return fptr_count;
+ return NULL;
}
/* }}} */