Bug #53119 [Asn->Opn]: LimitIterator(ArrayIterator)->seek() doesn't work correctly after OutOfBoundsE

From: Date: Tue, 24 Oct 2017 07:25:37 +0000
Subject: Bug #53119 [Asn->Opn]: LimitIterator(ArrayIterator)->seek() doesn't work correctly after OutOfBoundsE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212066@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53119&edit=1

 ID:                 53119
 Updated by:         kalle@php.net
 Reported by:        marc-bennewitz at arcor dot de
 Summary:            LimitIterator(ArrayIterator)->seek() doesn't work
                     correctly after OutOfBoundsE
-Status:             Assigned
+Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Linux
 PHP Version:        5.3.3
-Assigned To:        colder
+Assigned To:        
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2010-10-21 18:22:10] marc-bennewitz at arcor dot de

The LimitIterator should have the same behavior as the inner iterator (in this example
ArrayIterator) but on ArrayIterator there is no need to call rewind after an Exception.

------------------------------------------------------------------------
[2010-10-21 11:50:29] johannes@php.net

The exception leaves the iterator in undefined behavior. That is expected.

------------------------------------------------------------------------
[2010-10-20 20:47:02] marc-bennewitz at arcor dot de

Description:
------------
Seeking after an OutOfBoundException doesn't work without call of rewind.
With php < 5.3 it works as expected.

Test script:
---------------
$it = new ArrayIterator(array('zf9396', 'foo', null));
$it->rewind();

try {
    $it->seek(3);
} catch (OutOfBoundsException $e) {
    var_dump($it->key());
    $it->seek(0);
    var_dump($it->key());
}


$lit = new LimitIterator($it, 0, 10);
try {
    $lit->seek(3);
} catch (OutOfBoundsException $e) {
    var_dump($lit->key());
    $lit->seek(0);
    var_dump($lit->key());
}



Expected result:
----------------
NULL
int(0)
NULL
int(0)

Actual result:
--------------
NULL
int(0)
NULL
NULL


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=53119&edit=1


Thread (6 messages)

« previous php.bugs (#212066) next »