php.net |  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
Votes:5
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
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: mg at ovos dot at
New email:
PHP Version: OS:

 

 [2012-05-30 10:10 UTC] mg at ovos dot at
Description:
------------
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):

http://diffchecker.com/T40k97j7

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.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-30 12:08 UTC] cataphract@php.net
Can you create a short script that reproduces this behavior?
 [2012-05-30 12:08 UTC] cataphract@php.net
-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
Hello!

I managed to produce a simple testCase, please find it here:
http://pastebin.com/sw1ZwvNv
 [2012-05-30 13:26 UTC] mg at ovos dot at
I'm attaching a DIFF with output of the testCase:

http://diffchecker.com/5399UzhN
Left side: PHP 5.3.8
Right side: PHP 5.4.3
 [2012-05-30 16:44 UTC] cataphract@php.net
-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:
https://bugs.php.net/bug.php?id=36424

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] cataphract@php.net
-Status: Open +Status: Feedback
 [2012-06-04 14:09 UTC] mg at ovos dot at
Please have a look at the following scenario:
http://pastebin.com/QRWtX0dM

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):

http://3v4l.org/D7HIa

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.

Cheers,
Marcin
 [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 
script
 [2013-08-19 20:59 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2013-08-19 20:59 UTC] mike@php.net
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] mike@php.net
-Status: Open +Status: Not a bug
 [2013-08-20 07:19 UTC] mike@php.net
So, nothing I can do here, sorry.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 18:01:31 2024 UTC