tony2001                Wed Jun 27 12:38:20 2007 UTC

  Modified files:              
    /php-src/ext/spl    spl_array.c 
    /php-src/ext/spl/tests      iterator_026.phpt iterator_047.phpt 
  Log:
  apply corrected fix
  fix tests
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.126&r2=1.127&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.126 php-src/ext/spl/spl_array.c:1.127
--- php-src/ext/spl/spl_array.c:1.126   Wed Jun 27 12:17:29 2007
+++ php-src/ext/spl/spl_array.c Wed Jun 27 12:38:20 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.126 2007/06/27 12:17:29 tony2001 Exp $ */
+/* $Id: spl_array.c,v 1.127 2007/06/27 12:38:20 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -931,7 +931,7 @@
 {
        zval *object = getThis();
        spl_array_object *intern;
-       zval *array;
+       zval **array;
        long ar_flags = 0;
        zend_class_entry *ce_get_iterator = zend_ce_iterator;
 
@@ -942,36 +942,40 @@
 
        intern = (spl_array_object*)zend_object_store_get_object(object 
TSRMLS_CC);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|lC", &array, 
&ar_flags, &ce_get_iterator) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, 
&ar_flags, &ce_get_iterator) == FAILURE) {
                php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                return;
        }
 
+       if (Z_TYPE_PP(array) == IS_ARRAY) {
+               SEPARATE_ZVAL_IF_NOT_REF(array);
+       }
+
        if (ZEND_NUM_ARGS() > 2) {
                intern->ce_get_iterator = ce_get_iterator;
        }
 
        ar_flags &= ~SPL_ARRAY_INT_MASK;
 
-       if (Z_TYPE_P(array) == IS_OBJECT && (Z_OBJ_HT_P(array) == 
&spl_handler_ArrayObject || Z_OBJ_HT_P(array) == &spl_handler_ArrayIterator)) {
+       if (Z_TYPE_PP(array) == IS_OBJECT && (Z_OBJ_HT_PP(array) == 
&spl_handler_ArrayObject || Z_OBJ_HT_PP(array) == &spl_handler_ArrayIterator)) {
                zval_ptr_dtor(&intern->array);
                if (ZEND_NUM_ARGS() == 1)
                {
-                       spl_array_object *other = 
(spl_array_object*)zend_object_store_get_object(array TSRMLS_CC);
+                       spl_array_object *other = 
(spl_array_object*)zend_object_store_get_object(*array TSRMLS_CC);
                        ar_flags = other->ar_flags & ~SPL_ARRAY_INT_MASK;
                }               
                ar_flags |= SPL_ARRAY_USE_OTHER;
-               intern->array = array;
+               intern->array = *array;
        } else {
-               if (Z_TYPE_P(array) != IS_OBJECT && Z_TYPE_P(array) != 
IS_ARRAY) {
+               if (Z_TYPE_PP(array) != IS_OBJECT && Z_TYPE_PP(array) != 
IS_ARRAY) {
                        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                        zend_throw_exception(spl_ce_InvalidArgumentException, 
"Passed variable is not an array or object, using empty array instead", 0 
TSRMLS_CC);
                        return;
                }
                zval_ptr_dtor(&intern->array);
-               intern->array = array;
+               intern->array = *array;
        }
-       if (object == array) {
+       if (object == *array) {
                intern->ar_flags |= SPL_ARRAY_IS_SELF;
                intern->ar_flags &= ~SPL_ARRAY_USE_OTHER;
        } else {
@@ -979,12 +983,12 @@
        }
        intern->ar_flags |= ar_flags;
        ZVAL_ADDREF(intern->array);
-       if (Z_TYPE_P(array) == IS_OBJECT) {
-               zend_object_get_properties_t handler = Z_OBJ_HANDLER_P(array, 
get_properties);
+       if (Z_TYPE_PP(array) == IS_OBJECT) {
+               zend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, 
get_properties);
                if ((handler != std_object_handlers.get_properties && handler 
!= spl_array_get_properties)
                || !spl_array_get_hash_table(intern, 0 TSRMLS_CC)) {
                        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
-                       
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, 
"Overloaded object of type %v is not compatible with %v", 
Z_OBJCE_P(array)->name, intern->std.ce->name);
+                       
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, 
"Overloaded object of type %v is not compatible with %v", 
Z_OBJCE_PP(array)->name, intern->std.ce->name);
                        return;
                }
        }
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_026.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/spl/tests/iterator_026.phpt
diff -u php-src/ext/spl/tests/iterator_026.phpt:1.3 
php-src/ext/spl/tests/iterator_026.phpt:1.4
--- php-src/ext/spl/tests/iterator_026.phpt:1.3 Wed Dec 21 22:21:54 2005
+++ php-src/ext/spl/tests/iterator_026.phpt     Wed Jun 27 12:38:20 2007
@@ -20,15 +20,19 @@
 ?>
 ===DONE===
 <?php exit(0); ?>
---EXPECT--
+--EXPECTF--
 0=>1
 hasNext: yes
 1=>2
 hasNext: yes
+
+Notice: Array to string conversion in %s on line %d
 0=>31
 hasNext: yes
 1=>32
 hasNext: yes
+
+Notice: Array to string conversion in %s on line %d
 0=>331
 hasNext: no
 3=>4
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_047.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/iterator_047.phpt
diff -u php-src/ext/spl/tests/iterator_047.phpt:1.1 
php-src/ext/spl/tests/iterator_047.phpt:1.2
--- php-src/ext/spl/tests/iterator_047.phpt:1.1 Sun May 21 17:27:12 2006
+++ php-src/ext/spl/tests/iterator_047.phpt     Wed Jun 27 12:38:20 2007
@@ -72,6 +72,8 @@
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(10)
@@ -80,6 +82,8 @@
 int(2)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(30)
@@ -88,20 +92,22 @@
 int(4)
 ===1===
 MyRecursiveArrayIterator::hasChildren()
-Exception: State 1: MyRecursiveArrayIterator::hasChildren() in 
%siterator_047.php on line %d
+Exception: State 1: MyRecursiveArrayIterator::hasChildren() in %s on line %d
 ===2===
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
-Exception: State 2: MyRecursiveArrayIterator::getChildren() in 
%siterator_047.php on line %d
+Exception: State 2: MyRecursiveArrayIterator::getChildren() in %s on line %d
 ===3===
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(10)
@@ -110,6 +116,8 @@
 int(2)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(30)

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

Reply via email to