From c176114acb8182d2896a929d115ee8919d4f43ba Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 21 May 2009 13:25:48 +0000 Subject: [PATCH] Better fix for #45622 (patch by robinf at php do net) --- ext/spl/spl_array.c | 8 ++--- ext/spl/tests/arrayObject_magicMethods6.phpt | 3 -- ext/spl/tests/bug45622b.phpt | 33 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 ext/spl/tests/bug45622b.phpt diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 5b364dbf10c..555e9d09390 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -749,12 +749,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 c916a5c06c4..276b14f4312 100644 --- a/ext/spl/tests/arrayObject_magicMethods6.phpt +++ b/ext/spl/tests/arrayObject_magicMethods6.phpt @@ -143,11 +143,8 @@ object(UsesMagic)#2 (2) { } --> 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)#1 (5) { diff --git a/ext/spl/tests/bug45622b.phpt b/ext/spl/tests/bug45622b.phpt new file mode 100644 index 00000000000..9d49392111c --- /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