php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63163 Unserialisation incorrect in presented scenario
Submitted: 2012-09-25 19:49 UTC Modified: 2017-01-01 11:47 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: james at gadgets4vista dot co dot uk Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.4.7 OS: OS X 10.8.2
Private report: No CVE-ID: None
 [2012-09-25 19:49 UTC] james at gadgets4vista dot co dot uk
Description:
------------
So far as I can tell this problem is trigged by the serialisation/deserialisation 
going on in the inheritance hierarchy (ParentA and ParentB) in combination with 
the re-use (triggering obj references in the serialisation) of ParentB's children 
in Wrapper.

At a guess this is a difference in the table construction between serialize and 
unserialize (thus ending up referencing the incorrect thing), but I haven't yet 
taken a look at their implementation so that's a total stab in the dark.

Test script:
---------------
http://pastie.org/private/vbjpi8ytmqqxi2pkiizatw

Expected result:
----------------
object(Wrapper)#6 (2) {
  ["parent"]=>
  object(ParentB)#7 (2) {
    ["collection"]=>
    array(3) {
      [0]=>
      object(Child)#8 (1) {
        ["property"]=>
        string(3) "foo"
      }
      [1]=>
      object(Child)#9 (1) {
        ["property"]=>
        string(3) "foo"
      }
      [2]=>
      object(Child)#10 (1) {
        ["property"]=>
        string(3) "foo"
      }
    }
    ["rofl"]=>
    string(3) "foo"
  }
  ["children"]=>
  array(3) {
    [0]=>
    object(Child)#8 (1) {
      ["property"]=>
      string(3) "foo"
    }
    [1]=>
    object(Child)#9 (1) {
      ["property"]=>
      string(3) "foo"
    }
    [2]=>
    object(Child)#10 (1) {
      ["property"]=>
      string(3) "foo"
    }
  }
}

Actual result:
--------------
object(Wrapper)#6 (2) {
  ["parent"]=>
  object(ParentB)#7 (2) {
    ["collection"]=>
    array(3) {
      [0]=>
      object(Child)#8 (1) {
        ["property"]=>
        string(3) "foo"
      }
      [1]=>
      object(Child)#9 (1) {
        ["property"]=>
        string(3) "foo"
      }
      [2]=>
      object(Child)#10 (1) {
        ["property"]=>
        string(3) "foo"
      }
    }
    ["rofl"]=>
    string(3) "foo"
  }
  ["children"]=>
  array(3) {
    [0]=>
    object(Child)#9 (1) { <-- Where'd #8 go?
      ["property"]=>
      string(3) "foo"
    }
    [1]=>
    object(Child)#10 (1) {
      ["property"]=>
      string(3) "foo"
    }
    [2]=>
    string(20) "1Y"  <-- Unexpected
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-09 06:59 UTC] turneliusz at gmail dot com
Fixed in PHP7 and HVVM http://3v4l.org/WPdtA
 [2017-01-01 11:47 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2017-01-01 11:47 UTC] nikic@php.net
Closing as duplicate of newer bug #66085, which has more discussion about the root cause.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC