Bug #49906 [Asn->Opn]: LimitIterator doesn't work with un-/serialize

From: Date: Tue, 24 Oct 2017 07:26:00 +0000
Subject: Bug #49906 [Asn->Opn]: LimitIterator doesn't work with un-/serialize
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212072@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49906&edit=1

 ID:                 49906
 Updated by:         kalle@php.net
 Reported by:        marc-bennewitz at arcor dot de
 Summary:            LimitIterator doesn't work with un-/serialize
-Status:             Assigned
+Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Linux
 PHP Version:        5.3SVN-2009-10-16 (snap)
-Assigned To:        colder
+Assigned To:        
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2016-06-07 17:17:00] 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>

------------------------------------------------------------------------
[2009-10-17 00:12:31] 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());

------------------------------------------------------------------------
[2009-10-16 23:59:45] 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


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



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


Thread (4 messages)

« previous php.bugs (#212072) next »