[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] =?utf-8?q?svn:_/php/php-src/_branches/PHP=5F5=5F3/NEWS_branches/PHP=5F5=5F3/ext/spl/spl=5F
From: Pierrick_Charron <pierrick () php ! net>
Date: 2011-06-28 11:09:06
Message-ID: svn-pierrick-1309259346-312564-2115284830 () svn ! php ! net
[Download RAW message or body]
pierrick Tue, 28 Jun 2011 11:09:06 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=312564
Log:
Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
Bug: http://bugs.php.net/54971 (unknown)
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c
A php/php-src/branches/PHP_5_3/ext/spl/tests/bug54971.phpt
U php/php-src/branches/PHP_5_4/ext/spl/spl_iterators.c
A php/php-src/branches/PHP_5_4/ext/spl/tests/bug54971.phpt
U php/php-src/trunk/ext/spl/spl_iterators.c
A php/php-src/trunk/ext/spl/tests/bug54971.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-06-28 11:03:16 UTC (rev 312563)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-06-28 11:09:06 UTC (rev 312564)
@@ -14,6 +14,9 @@
- PDO ODBC driver:
. Fixed data type usage in 64bit. (leocsilva at gmail dot com)
+- SPL extension:
+ . Fixed bug #54971 (Wrong result when using iterator_to_array with use_keys
+ on true). (Pierrick)
16 Jun 2011, PHP 5.3.7 RC1
- Upgraded bundled SQLite to version 3.7.6.3. (Scott)
Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c 2011-06-28 11:03:16 UTC (rev 312563)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c 2011-06-28 11:09:06 UTC (rev 312564)
@@ -3306,6 +3306,7 @@
goto done;
}
+ iter->index = 0;
if (iter->funcs->rewind) {
iter->funcs->rewind(iter TSRMLS_CC);
if (EG(exception)) {
@@ -3320,6 +3321,7 @@
if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) {
goto done;
}
+ iter->index++;
iter->funcs->move_forward(iter TSRMLS_CC);
if (EG(exception)) {
goto done;
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug54971.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug54971.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug54971.phpt 2011-06-28 11:09:06 UTC (rev 312564)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
+--FILE--
+<?php
+
+$source = <<<XML
+<root>
+<node>val1</node>
+<node>val2</node>
+</root>
+XML;
+
+
+$doc = new DOMDocument();
+$doc->loadXML($source);
+
+$xpath = new DOMXPath($doc);
+$items = $xpath->query('//node');
+
+print_r(iterator_to_array($items, false));
+print_r(iterator_to_array($items, true));
+?>
+--EXPECT--
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
Modified: php/php-src/branches/PHP_5_4/ext/spl/spl_iterators.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/spl_iterators.c 2011-06-28 11:03:16 UTC (rev 312563)
+++ php/php-src/branches/PHP_5_4/ext/spl/spl_iterators.c 2011-06-28 11:09:06 UTC (rev 312564)
@@ -3446,6 +3446,7 @@
goto done;
}
+ iter->index = 0;
if (iter->funcs->rewind) {
iter->funcs->rewind(iter TSRMLS_CC);
if (EG(exception)) {
@@ -3460,6 +3461,7 @@
if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) {
goto done;
}
+ iter->index++;
iter->funcs->move_forward(iter TSRMLS_CC);
if (EG(exception)) {
goto done;
Added: php/php-src/branches/PHP_5_4/ext/spl/tests/bug54971.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/tests/bug54971.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/spl/tests/bug54971.phpt 2011-06-28 11:09:06 UTC (rev 312564)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
+--FILE--
+<?php
+
+$source = <<<XML
+<root>
+<node>val1</node>
+<node>val2</node>
+</root>
+XML;
+
+
+$doc = new DOMDocument();
+$doc->loadXML($source);
+
+$xpath = new DOMXPath($doc);
+$items = $xpath->query('//node');
+
+print_r(iterator_to_array($items, false));
+print_r(iterator_to_array($items, true));
+?>
+--EXPECT--
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
Modified: php/php-src/trunk/ext/spl/spl_iterators.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_iterators.c 2011-06-28 11:03:16 UTC (rev 312563)
+++ php/php-src/trunk/ext/spl/spl_iterators.c 2011-06-28 11:09:06 UTC (rev 312564)
@@ -3446,6 +3446,7 @@
goto done;
}
+ iter->index = 0;
if (iter->funcs->rewind) {
iter->funcs->rewind(iter TSRMLS_CC);
if (EG(exception)) {
@@ -3460,6 +3461,7 @@
if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) {
goto done;
}
+ iter->index++;
iter->funcs->move_forward(iter TSRMLS_CC);
if (EG(exception)) {
goto done;
Added: php/php-src/trunk/ext/spl/tests/bug54971.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug54971.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug54971.phpt 2011-06-28 11:09:06 UTC (rev 312564)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
+--FILE--
+<?php
+
+$source = <<<XML
+<root>
+<node>val1</node>
+<node>val2</node>
+</root>
+XML;
+
+
+$doc = new DOMDocument();
+$doc->loadXML($source);
+
+$xpath = new DOMXPath($doc);
+$items = $xpath->query('//node');
+
+print_r(iterator_to_array($items, false));
+print_r(iterator_to_array($items, true));
+?>
+--EXPECT--
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
+Array
+(
+ [0] => DOMElement Object
+ (
+ )
+
+ [1] => DOMElement Object
+ (
+ )
+
+)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic