php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49906 LimitIterator doesn't work with un-/serialize
Submitted: 2009-10-16 23:59 UTC Modified: 2009-10-17 11:13 UTC
Votes:11
Avg. Score:4.5 ± 0.8
Reproduced:9 of 9 (100.0%)
Same Version:4 (44.4%)
Same OS:7 (77.8%)
From: marc-bennewitz at arcor dot de Assigned: colder
Status: Assigned Package: SPL related
PHP Version: 5.3SVN-2009-10-16 (snap) OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-10-16 23:59 UTC] marc-bennewitz at arcor dot de
Description:
------------
Serializing of LimitIterator doesn't work.


Reproduce code:
---------------
$it = new ArrayIterator(array('test' => 'test'));

$limitit = new LimitIterator($it, 0, 10);
var_dump($limitit);
var_dump($limitit->getInnerIterator());

$limititSer = serialize($limitit);
var_dump($limititSer);

$limitit = unserialize($limititSer);
var_dump($limitit);
var_dump($limitit->getInnerIterator());

Expected result:
----------------
object(LimitIterator)#2 (0) {
  /* some content */
}
object(ArrayIterator)#1 (1) {
  ["storage":"ArrayIterator":private]=>
  array(1) {
    ["test"]=>
    string(4) "test"
  }
}
string(25) "O:13:"LimitIterator":0:{...........}"
object(LimitIterator)#3 (0) {
  /* some content */
}
object(ArrayIterator)#1 (1) {
  ["storage":"ArrayIterator":private]=>
  array(1) {
    ["test"]=>
    string(4) "test"
  }
}

Actual result:
--------------
object(LimitIterator)#2 (0) {
}
object(ArrayIterator)#1 (1) {
  ["storage":"ArrayIterator":private]=>
  array(1) {
    ["test"]=>
    string(4) "test"
  }
}
string(25) "O:13:"LimitIterator":0:{}"
object(LimitIterator)#3 (0) {
}
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-17 00:12 UTC] marek at flaber dot net
When you actually trying to rewind the object it is making php to 
segfault.

Like here:

$limitit = unserialize( serialize($limitit) );
echo $limitit->next();
var_dump($limitit->getInnerIterator());
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 08:02:55 2014 UTC