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: 2017-10-24 07:25 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:
Status: Open Package: SPL related
PHP Version: 5.3SVN-2009-10-16 (snap) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marc-bennewitz at arcor dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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());
 [2016-06-07 17:17 UTC] cmb@php.net
FWIW: as of PHP 5.3.7 there is an error thrown when
$limitit->getInnerIterator() is called[1]:

| Fatal error: Uncaught exception 'LogicException' with message
| 'The object is in an invalid state as the parent constructor was
| not called' in …

[1] <https://3v4l.org/9aOX8>
 [2017-10-24 07:25 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: colder +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC