svn: /php/php-src/ branches/PHP_5_2/ext/spl/spl_iterators.c branches/PHP_5_2/ext/spl/tests/bug49723.phpt branches/PHP_5_3/ext/spl/spl_iterators.c
branches/PHP_5_3/ext/spl/tests/bug49723.phpt trunk/ext/spl/spl_iterators.c trunk/ext/spl/tests/bug49723.phpt
| From: | Etienne Kneuss | Date: | Tue, 27 Apr 2010 04:57:48 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_2/ext/spl/spl_iterators.c branches/PHP_5_2/ext/spl/tests/bug49723.phpt branches/PHP_5_3/ext/spl/spl_iterators.c branches/PHP_5_3/ext/spl/tests/bug49723.phpt trunk/ext/spl/spl_iterators.c trunk/ext/spl/tests/bug49723.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-62425@lists.php.net to get a copy of this message | ||
colder Tue, 27 Apr 2010 04:57:48 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=298633
Log:
Fix #49723 (Skip seek when unnecessary)
Bug: http://bugs.php.net/49723 (Assigned) LimitIterator with
empty ArrayIterator
Changed paths:
U php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c
A php/php-src/branches/PHP_5_2/ext/spl/tests/bug49723.phpt
U php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c
A php/php-src/branches/PHP_5_3/ext/spl/tests/bug49723.phpt
U php/php-src/trunk/ext/spl/spl_iterators.c
A php/php-src/trunk/ext/spl/tests/bug49723.phpt
Modified: php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c 2010-04-27 01:33:35 UTC (rev 298632)
+++ php/php-src/branches/PHP_5_2/ext/spl/spl_iterators.c 2010-04-27 04:57:48 UTC (rev 298633)
@@ -1738,7 +1738,7 @@
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which
is behind offset %ld plus count %ld", pos, intern->u.limit.offset,
intern->u.limit.count);
return;
}
- if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
+ if (pos != intern->current.pos && instanceof_function(intern->inner.ce,
spl_ce_SeekableIterator TSRMLS_CC)) {
MAKE_STD_ZVAL(zpos);
ZVAL_LONG(zpos, pos);
spl_dual_it_free(intern TSRMLS_CC);
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/bug49723.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/bug49723.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/bug49723.phpt 2010-04-27 04:57:48 UTC (rev 298633)
@@ -0,0 +1,16 @@
+--TEST--
+LimitIterator: do not seek if not needed
+--FILE--
+<?php
+
+$it = new ArrayIterator(array());
+
+$lit = new LimitIterator($it, 0, 5);
+
+foreach ($lit as $v) {
+ echo $v;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===
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 2010-04-27 01:33:35 UTC (rev 298632)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c 2010-04-27 04:57:48 UTC (rev 298633)
@@ -2080,7 +2080,7 @@
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which
is behind offset %ld plus count %ld", pos, intern->u.limit.offset,
intern->u.limit.count);
return;
}
- if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
+ if (pos != intern->current.pos && instanceof_function(intern->inner.ce,
spl_ce_SeekableIterator TSRMLS_CC)) {
MAKE_STD_ZVAL(zpos);
ZVAL_LONG(zpos, pos);
spl_dual_it_free(intern TSRMLS_CC);
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug49723.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug49723.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug49723.phpt 2010-04-27 04:57:48 UTC (rev 298633)
@@ -0,0 +1,16 @@
+--TEST--
+LimitIterator: do not seek if not needed
+--FILE--
+<?php
+
+$it = new ArrayIterator(array());
+
+$lit = new LimitIterator($it, 0, 5);
+
+foreach ($lit as $v) {
+ echo $v;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===
Modified: php/php-src/trunk/ext/spl/spl_iterators.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_iterators.c 2010-04-27 01:33:35 UTC (rev 298632)
+++ php/php-src/trunk/ext/spl/spl_iterators.c 2010-04-27 04:57:48 UTC (rev 298633)
@@ -2080,7 +2080,7 @@
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which
is behind offset %ld plus count %ld", pos, intern->u.limit.offset,
intern->u.limit.count);
return;
}
- if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
+ if (pos != intern->current.pos && instanceof_function(intern->inner.ce,
spl_ce_SeekableIterator TSRMLS_CC)) {
MAKE_STD_ZVAL(zpos);
ZVAL_LONG(zpos, pos);
spl_dual_it_free(intern TSRMLS_CC);
Added: php/php-src/trunk/ext/spl/tests/bug49723.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug49723.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug49723.phpt 2010-04-27 04:57:48 UTC (rev 298633)
@@ -0,0 +1,16 @@
+--TEST--
+LimitIterator: do not seek if not needed
+--FILE--
+<?php
+
+$it = new ArrayIterator(array());
+
+$lit = new LimitIterator($it, 0, 5);
+
+foreach ($lit as $v) {
+ echo $v;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===