]> granicus.if.org Git - php/commitdiff
- MFH Fix Bug #40872 (inconsistency in offsetSet, offsetExists treatment
authorMarcus Boerger <helly@php.net>
Tue, 20 Mar 2007 20:28:08 +0000 (20:28 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 20 Mar 2007 20:28:08 +0000 (20:28 +0000)
  of string enclosed integers)

NEWS
ext/spl/spl_array.c
ext/spl/tests/bug40872.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 9515e32a19205353f29eee693f7b5e646195023a..03a33b9fc9cb7e801055eac9bcc598690f4d245b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP                                                                        NEWS
 - Improved SPL (Marcus)
   . Added SplFileInfo::getBasename(), DirectoryIterator::getBasename().
   . Added SplFileInfo::getLinkTarget(), SplFileInfo::getRealPath().
+  . Made RecursiveFilterIterator::accept() abstract as stated in documentation.
 - Improved SOAP
   . Added ability to encode arrays with "SOAP-ENC:Array" type instead of WSDL
     type. To activate the ability use "feature"=>SOAP_USE_XSI_ARRAY_TYPE
@@ -29,6 +30,8 @@ PHP                                                                        NEWS
 - Fixed zend_llist_remove_tail (Michael Wallner, Dmitry)
 - Fixed a thread safety issue in gd gif read code (Nuno, Roman Nemecek)
 - Fixed CVE-2007-1001, GD wbmp used with invalid image size (Pierre)
+- Fixed bug #40872 (inconsistency in offsetSet, offsetExists treatment of 
+  string enclosed integers). (Marcus)
 - Fixed bug #40854 (imap_mail_compose() creates an invalid terminator for 
   multipart e-mails). (Ilia)
 - Fixed bug #40848 (sorting issue on 64-bit Solaris). (Wez)
index 419eb52e38c42fcd4bc3a71cceb65812f01bfb06..fec74f57f98935ec04369ce73519becb3bc228ac 100755 (executable)
@@ -456,7 +456,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
 {
        spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
        long index;
-       zval *rv;
+       zval *rv, **tmp;
 
        if (check_inherited && intern->fptr_offset_has) {
                SEPARATE_ARG_IF_REF(offset);
@@ -475,9 +475,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
        switch(Z_TYPE_P(offset)) {
        case IS_STRING:
                if (check_empty) {
-                       zval **tmp;
-                       HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-                       if (zend_hash_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE && zend_is_true(*tmp)) {
+                       if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE && zend_is_true(*tmp)) {
                                return 1;
                        }
                        return 0;
diff --git a/ext/spl/tests/bug40872.phpt b/ext/spl/tests/bug40872.phpt
new file mode 100755 (executable)
index 0000000..a48fe74
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #40872 (inconsistency in offsetSet, offsetExists treatment of string enclosed integers)
+--FILE--
+<?php
+       class Project {
+               public $id;
+
+               function __construct($id) {
+                       $this->id = $id;
+               }
+       }
+
+       class ProjectsList extends ArrayIterator {
+               public function add(Project $item) {
+                       $this->offsetSet($item->id, $item);
+               }
+       }
+
+       $projects = new ProjectsList();
+       $projects->add(new Project('1'));
+       $projects->add(new Project(2));
+
+       var_dump($projects->offsetExists(1));
+       var_dump($projects->offsetExists('2'));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(true)
+===DONE===