dmitry          Fri Oct 21 11:20:31 2005 EDT

  Modified files:              
    /php-src/ext/standard       array.c 
    /php-src/ext/standard/tests/array   bug34934.phpt 
  Log:
  Fixed bug #34934 (offsetExists is not called from array_key_exists)
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.327&r2=1.328&ty=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.327 php-src/ext/standard/array.c:1.328
--- php-src/ext/standard/array.c:1.327  Tue Oct  4 16:47:48 2005
+++ php-src/ext/standard/array.c        Fri Oct 21 11:20:30 2005
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.327 2005/10/04 20:47:48 tony2001 Exp $ */
+/* $Id: array.c,v 1.328 2005/10/21 15:20:30 dmitry Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -4658,6 +4658,17 @@
                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), 
U_CLASS_ENTRY(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:
                case IS_UNICODE:
http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug34934.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/standard/tests/array/bug34934.phpt
diff -u /dev/null php-src/ext/standard/tests/array/bug34934.phpt:1.2
--- /dev/null   Fri Oct 21 11:20:31 2005
+++ php-src/ext/standard/tests/array/bug34934.phpt      Fri Oct 21 11:20:30 2005
@@ -0,0 +1,18 @@
+--TEST--
+Bug #34934 (offsetExists is not called from array_key_exists)
+--FILE--
+<?php
+class MyArray extends ArrayObject {
+  function offsetExists($mKey) { 
+       echo __METHOD__ . "($mKey)\n";
+       return true;
+  }
+}
+
+$a = new MyArray();
+
+var_dump(array_key_exists("test", $a));
+?>
+--EXPECT--
+MyArray::offsetExists(test)
+bool(true)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to