From: Christoph M. Becker Date: Mon, 27 Apr 2020 08:07:54 +0000 (+0200) Subject: Merge branch 'PHP-7.4' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecc6b8cc29ff33ea6ea2c21ef755732e1d2dc109;p=php Merge branch 'PHP-7.4' * PHP-7.4: Fix #79065: DOM classes do not expose properties to Reflection --- ecc6b8cc29ff33ea6ea2c21ef755732e1d2dc109 diff --cc ext/dom/php_dom.c index c7b2103a0f,ad297ca778..67961b303a --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@@ -385,9 -410,31 +385,31 @@@ static int dom_property_exists(zend_obj } /* }}} */ + /* {{{ dom_get_properties */ -static HashTable *dom_get_properties(zval *object) ++static HashTable *dom_get_properties(zend_object *object) + { - dom_object *obj = Z_DOMOBJ_P(object); ++ dom_object *obj = php_dom_obj_from_obj(object); + HashTable *props = zend_std_get_properties(object); + + if (obj->prop_handler != NULL) { + zend_string *key; + dom_prop_handler *hnd; + + ZEND_HASH_FOREACH_STR_KEY_PTR(obj->prop_handler, key, hnd) { + zval val; + + if (hnd->read_func(obj, &val) == SUCCESS) { + zend_hash_update(props, key, &val); + } + } ZEND_HASH_FOREACH_END(); + } + return props; + } + /* }}} */ + -static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ */ +static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */ { - dom_object *obj = Z_DOMOBJ_P(object); + dom_object *obj = php_dom_obj_from_obj(object); HashTable *debug_info, *prop_handlers = obj->prop_handler, *std_props; diff --cc ext/dom/tests/bug79065.phpt index 0000000000,9f3f49b7c8..5b92d5c749 mode 000000,100644..100644 --- a/ext/dom/tests/bug79065.phpt +++ b/ext/dom/tests/bug79065.phpt @@@ -1,0 -1,30 +1,30 @@@ + --TEST-- + Bug #79065 (DOM classes do not expose properties to Reflection) + --SKIPIF-- + + --FILE-- + loadHTML('test'); + var_dump(count(get_object_vars($dom))); + + $ro = new ReflectionObject($dom); + var_dump(count($ro->getProperties())); + var_dump($ro->hasProperty("textContent")); + $rp = $ro->getProperty("textContent"); + var_dump($rp); + var_dump($rp->getValue($dom)); + ?> + --EXPECTF-- -int(35) -int(35) ++int(38) ++int(38) + bool(true) + object(ReflectionProperty)#%d (2) { + ["name"]=> + string(11) "textContent" + ["class"]=> + string(11) "DOMDocument" + } + string(4) "test"