|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62189 Behavior of serialize has changed
Submitted: 2012-05-30 10:10 UTC Modified: 2013-08-20 07:19 UTC
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:1 (20.0%)
From: mg at ovos dot at Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.4.3 OS: Win64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
20 + 38 = ?
Subscribe to this entry?

 [2012-05-30 10:10 UTC] mg at ovos dot at
There is a difference in output of the same object serialized in PHP 5.4 and lower than 5.4. Although I could not create a simple testCase, it seems to be related to referencing the same object more than once.

I include an online DIFF of serialize() output from PHP 5.3.8 (left column) and PHP 5.4.3 (right column):

The object is 100% the same, I am just switching between PHP versions.

As you can see the references to "Placeholder" object with name "Left column (Homepage)" are present multiple times in output from 5.3.8, where in output from PHP 5.4 it is present just once. All the additional occurences are marked as reference (e.g. "r: 204"), but the objects are not re-created after running unserialize().
Instead of valid objects, empty arrays are created - this is where the change breaks down our application.

I would appreciate any hints on why the output might be different.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-30 12:08 UTC]
Can you create a short script that reproduces this behavior?
 [2012-05-30 12:08 UTC]
-Status: Open +Status: Feedback
 [2012-05-30 12:14 UTC] mg at ovos dot at
Hello, I am working on a test script. Please allow me to include it in few hours.
 [2012-05-30 13:20 UTC] mg at ovos dot at

I managed to produce a simple testCase, please find it here:
 [2012-05-30 13:26 UTC] mg at ovos dot at
I'm attaching a DIFF with output of the testCase:
Left side: PHP 5.3.8
Right side: PHP 5.4.3
 [2012-05-30 16:44 UTC]
-Status: Feedback +Status: Open
 [2012-05-30 17:22 UTC] mg at ovos dot at
It seems that my issue is directly related to fixing a bug in PHP:

If this is true, the test case I included does not cover entirely the issue I am having. In my case unserialize() does not bring back the referenced object, although the test case does.

I had no luck in extracting my scenario into a test case as yet. I am trying to find the difference between test case and the live case, which is obviosly many times more complex.
 [2012-05-31 13:28 UTC]
-Status: Open +Status: Feedback
 [2012-06-04 14:09 UTC] mg at ovos dot at
Please have a look at the following scenario:

Of course such double serialization makes no sense, but I found it to be present in Doctrine 1.2 library. Therefore I am wondering if the references should still work in this case like it was in PHP 5.3.
 [2012-06-12 12:45 UTC] mg at ovos dot at
Feedback -> Open.
 [2012-06-12 12:45 UTC] mg at ovos dot at
-Status: Feedback +Status: Open
 [2012-06-23 14:25 UTC] Sjon at hortensius dot net
Have a look at this example (based on your code):

Before 5.4, the Placeholder instances were actually different objects. This was 
fixed in 5.4, therefore the properties correctly reference to the same objects.

Regarding your bug, where objects are NOT properly recreated, I am afraid you 
will need to create an actual reproducable testcase before expecting anyone to 
take a look at it :)
 [2012-06-23 21:13 UTC] mg at ovos dot at
Dear Sjon,

You stripped it from the key lines, no wonder you cannot reproduce it.
It is all about the lines that you removed.

 [2012-06-24 09:04 UTC] Sjon at hortensius dot net
Maybe you misread my comment, or misinterpreted the results demonstrated. I can 
reproduce your described behavior perfectly using the script I posted. In the 
results I posted, 5.4 references only Placeholder#8 and #10, while 5.3 and 
earlier contains references to Placeholder#8, #10, #12 and #14; demonstrating 
what was fixed in 5.4

again, this behaviour is better in 5.4 and there is no bug demonstrated in that 
 [2013-08-19 20:59 UTC]
-Status: Open +Status: Feedback
 [2013-08-19 20:59 UTC]
Duh, well, I'm lost :) So do we have a bug here, or not? And if so, what is it?
 [2013-08-20 06:11 UTC] mg at ovos dot at
-Status: Feedback +Status: Open
 [2013-08-20 06:11 UTC] mg at ovos dot at
I come accross it from time to time, but i'm unable to extract a standalone test case. In general some strings are broken when using unserialize on objects, I usually fix it by using another value :/ It happend on both Linux and Windows servers.
 [2013-08-20 07:19 UTC]
-Status: Open +Status: Not a bug
 [2013-08-20 07:19 UTC]
So, nothing I can do here, sorry.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 10:01:33 2024 UTC