From: Dmitry Stogov Date: Fri, 21 Oct 2005 15:19:40 +0000 (+0000) Subject: Fixed bug #34934 (offsetExists is not called from array_key_exists) X-Git-Tag: php-5.1.0RC4~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75a548a7e9af51f2fa6cceac34564ccf50ef9740;p=php Fixed bug #34934 (offsetExists is not called from array_key_exists) --- diff --git a/NEWS b/NEWS index 5907a6d68f..885d442c7b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Oct 2005, PHP 5.1 Release Candidate 4 - Fixed fgetcsv() and fputcsv() inconsistency. (Dmitry) +- Fixed bug #34934 (offsetExists is not called from array_key_exists). (Dmitry) - Fixed bug #34905 (Digest authentication does not work with Apache 1). (Ilia) - Fixed bug #34902 (mysqli::character_set_name() - undefined method). (Tony) - Fixed bug #34893 (PHP5.1 overloading, Cannot access private property). diff --git a/ext/standard/array.c b/ext/standard/array.c index fd9f2af36f..40372e99b6 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4390,6 +4390,17 @@ PHP_FUNCTION(array_key_exists) RETURN_FALSE; } + if (Z_TYPE_PP(array) == IS_OBJECT && + Z_OBJ_HT_PP(array)->has_dimension && + (Z_OBJ_HT_PP(array)->has_dimension != std_object_handlers.has_dimension || + instanceof_function_ex(Z_OBJCE_PP(array), zend_ce_arrayaccess, 1 TSRMLS_CC))) { + if (Z_OBJ_HT_PP(array)->has_dimension(*array, *key, 0 TSRMLS_CC)) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } + } + switch (Z_TYPE_PP(key)) { case IS_STRING: if (zend_symtable_exists(HASH_OF(*array), Z_STRVAL_PP(key), Z_STRLEN_PP(key)+1)) { diff --git a/ext/standard/tests/array/bug34934.phpt b/ext/standard/tests/array/bug34934.phpt new file mode 100755 index 0000000000..1f5d161f30 --- /dev/null +++ b/ext/standard/tests/array/bug34934.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #34934 (offsetExists is not called from array_key_exists) +--FILE-- + +--EXPECT-- +MyArray::offsetExists(test) +bool(true)