MFH: Better fix for #45622 (patch by robinf at php do net)

This commit is contained in:
Arnaud Le Blanc 2009-05-21 13:26:14 +00:00
parent 44fe1bf83f
commit 52cc098a90
3 changed files with 37 additions and 7 deletions

View File

@ -745,12 +745,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) /* {{{ */

View File

@ -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) {

View File

@ -0,0 +1,33 @@
--TEST--
Ensure fix to bug45622 doesn't cause __isset() to be called when ArrayObject::ARRAY_AS_PROPS is used.
--FILE--
<?php
class UsesMagic extends ArrayObject {
function __get($n) { echo "In " . __METHOD__ . "!\n"; }
function __set($n, $v) { echo "In " . __METHOD__ . "!\n"; }
function __isset($n) { echo "In " . __METHOD__ . "!\n"; }
function __unset($n) { echo "In " . __METHOD__ . "!\n"; }
}
$ao = new UsesMagic(array(), ArrayObject::ARRAY_AS_PROPS);
echo "Doesn't trigger __get.\n";
echo $ao->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.