php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41528 Classes extending ArrayObject do not serialize correctly
Submitted: 2007-05-29 10:48 UTC Modified: 2007-12-17 15:16 UTC
Votes:10
Avg. Score:4.9 ± 0.3
Reproduced:10 of 10 (100.0%)
Same Version:3 (30.0%)
Same OS:8 (80.0%)
From: m dot stach at ewerk dot com Assigned: davidc (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.* OS: *
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 stach at ewerk dot com
New email:
PHP Version: OS:

 

 [2007-05-29 10:48 UTC] m dot stach at ewerk dot com
Description:
------------
If a class extends ArrayObject, serializing does not work correctly. All properties are missing after unserializing, only the array contents are remain.

ArrayObjects (un)serializes without problems and does not implement the Serializable interface, so there seems no need to change the implementation of that interface.

The documentation mentions that it is not possible to serialize objects of internal class. Since ArrayObject itself serializes fine, I regard ArrayObject as "non-internal".

May be this is a documentation bug. But this would IMHO limit the broad use of the ArrayObject class.

Reproduce code:
---------------
class a extends ArrayObject {
	public $a = 2;
}
	
$a = new a();
$a->a = 1;

var_dump($a);
var_dump($a->a);

$a = unserialize(serialize($a));

var_dump($a);
var_dump($a->a);


Expected result:
----------------
object(a)#1 (1) { ["a"]=>  int(1) }
int(1) 

object(a)#1 (1) { ["a"]=>  int(1) } 
int(1) 


Actual result:
--------------
object(a)#1 (0) { } 
int(1)

object(a)#2 (0) { } 
int(2)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-05 15:31 UTC] pcdinh at gmail dot com
This bug remain still on PHP 5.2.4RC1
 [2007-12-06 16:06 UTC] helly@php.net
There is a fix for it in 5.3.0 that needs a few tweaks, you can test it for your usage already though. Assigning to david to do the tweaking.
 [2007-12-17 15:16 UTC] davidc@php.net
This bug has been fixed in CVS.

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.


 [2011-03-18 15:42 UTC] jachym dot tousek at gmail dot com
I've the same problem in PHP 5.3.5 / Windows 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 03:01:32 2024 UTC