php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49263 SplObjectStorage fails to serialize references
Submitted: 2009-08-14 20:46 UTC Modified: 2009-10-06 13:35 UTC
From: m dot kurzyna at crystalpoint dot pl Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.0 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: m dot kurzyna at crystalpoint dot pl
New email:
PHP Version: OS:

 

 [2009-08-14 20:46 UTC] m dot kurzyna at crystalpoint dot pl
Description:
------------
splObjectStorage fails to keep objects stored properly when they are internally referenced (see ["obj"]=> NULL in the dump).



Reproduce code:
---------------
$o1 = new stdClass;
$o2 = new stdClass;

$s = new splObjectStorage();

$s[$o1] = array('prev' => null, 'next' => $o2);
$s[$o2] = array('prev' => $o1, 'next' => null);

var_dump(unserialize(serialize($s)));


Expected result:
----------------
object(SplObjectStorage)#3 (1) {
  ["storage":"SplObjectStorage":private]=>
  array(2) {
    ["000000003696c2e400000000eec51f06"]=>
    array(2) {
      ["obj"]=>
      object(stdClass)#1 (0) {
      }
      ["inf"]=>
      array(2) {
        ["prev"]=>
        NULL
        ["next"]=>
        object(stdClass)#2 (0) {
        }
      }
    }
    ["000000003696c2e700000000eec51f06"]=>
    array(2) {
      ["obj"]=>
      object(stdClass)#2 (0) {
      }
      ["inf"]=>
      array(2) {
        ["prev"]=>
        object(stdClass)#1 (0) {
        }
        ["next"]=>
        NULL
      }
    }
  }
}

Actual result:
--------------
object(SplObjectStorage)#4 (1) {
  ["storage":"SplObjectStorage":private]=>
  array(2) {
    ["000000003696c2e000000000eec51f06"]=>
    array(2) {
      ["obj"]=>
      object(stdClass)#5 (0) {
      }
      ["inf"]=>
      array(2) {
        ["prev"]=>
        NULL
        ["next"]=>
        object(stdClass)#6 (0) {
        }
      }
    }
    ["000000003696c2e500000000593811c6"]=>
    array(2) {
      ["obj"]=>
      NULL
      ["inf"]=>
      array(2) {
        ["prev"]=>
        object(stdClass)#5 (0) {
        }
        ["next"]=>
        NULL
      }
    }
  }
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-06 13:34 UTC] svn@php.net
Automatic comment from SVN on behalf of colder
Revision: http://svn.php.net/viewvc/?view=revision&revision=289250
Log: Fix bug #49263 (Offset error when unserializing self-references in SplObjectStorage)
 [2009-10-06 13:35 UTC] colder@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 03:01:32 2024 UTC