From: Arnaud Le Blanc Date: Thu, 21 May 2009 13:26:29 +0000 (+0000) Subject: MFH: Better fix for #45622 (patch by robinf at php do net) X-Git-Tag: php-5.2.10RC1~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=011547bd36af78663e1b911f7ab027a3d9197a8b;p=php MFH: Better fix for #45622 (patch by robinf at php do net) --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index b9c7867483..2c48923a3a 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -671,12 +671,12 @@ static int spl_array_has_property(zval *object, zval *member, int has_set_exists { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - if (std_object_handlers.has_property(object, member, has_set_exists TSRMLS_CC)) { - return 1; - } else if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0) { + if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 + && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) { return spl_array_has_dimension(object, member, has_set_exists TSRMLS_CC); } - return 0; + return std_object_handlers.has_property(object, member, has_set_exists TSRMLS_CC); + } /* }}} */ static void spl_array_unset_property(zval *object, zval *member TSRMLS_DC) /* {{{ */ diff --git a/ext/spl/tests/arrayObject_magicMethods6.phpt b/ext/spl/tests/arrayObject_magicMethods6.phpt index b274d34cc4..427b1d4f20 100644 --- a/ext/spl/tests/arrayObject_magicMethods6.phpt +++ b/ext/spl/tests/arrayObject_magicMethods6.phpt @@ -133,11 +133,8 @@ object(UsesMagic)#%d (5) { } --> isset existent, non-existent and dynamic: -In UsesMagic::__isset(a) bool(true) -In UsesMagic::__isset(nonexistent) bool(false) -In UsesMagic::__isset(dynamic) bool(true) Original wrapped object: object(C)#%d (5) { diff --git a/ext/spl/tests/bug45622b.phpt b/ext/spl/tests/bug45622b.phpt new file mode 100644 index 0000000000..9d49392111 --- /dev/null +++ b/ext/spl/tests/bug45622b.phpt @@ -0,0 +1,33 @@ +--TEST-- +Ensure fix to bug45622 doesn't cause __isset() to be called when ArrayObject::ARRAY_AS_PROPS is used. +--FILE-- +prop1; + +echo "Doesn't trigger __set.\n"; +$ao->prop2 = 'foo'; + +echo "Doesn't trigger __unset.\n"; +unset($ao->prop3); + +echo "Shouldn't trigger __isset.\n"; +isset($ao->prop4); +?> +--EXPECTF-- +Doesn't trigger __get. + +Notice: Undefined index: prop1 in %s on line 11 +Doesn't trigger __set. +Doesn't trigger __unset. + +Notice: Undefined index: prop3 in %s on line 17 +Shouldn't trigger __isset. \ No newline at end of file