|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39635 Better control for serialization (keyword for permit property serialization)
Submitted: 2006-11-26 11:40 UTC Modified: 2017-10-24 06:12 UTC
Avg. Score:4.6 ± 0.7
Reproduced:12 of 12 (100.0%)
Same Version:7 (58.3%)
Same OS:8 (66.7%)
From: t dot prochazka at centrum dot cz Assigned:
Status: Open Package: *General Issues
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: t dot prochazka at centrum dot cz
New email:
PHP Version: OS:


 [2006-11-26 11:40 UTC] t dot prochazka at centrum dot cz
PHP has no advanced support for serialization.

I think, that is problem, that PHP serialize all properties. What about add single keyword (as transient) for property which can't be serializable?


class Foo {
 public $a;
 public transient $b;


Description of Java transient keyword:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-25 15:54 UTC] spam at thishell dot com
While it is possible to exclude members from serialization using __sleep(), it has downsides:
- Using get_object_vars($this) to return the members is extremely slow
- Manually maintaining an array with the members is error prone and can be quite some work

A transient keyword to exclude members from serialization would make it easier ...
 [2009-11-09 15:53 UTC] tjerkw at gmail dot com
Using a transient keyword is better because if we have the following 

class A { $a; $b; }
class B extends A { $c  function __sleep() { return array("c"); } }

now if you serialize b you will not serialize the $a and $b members from 
class A. So the sleep functions actually changes the encapsulated 
behaviour of A. Or we should call the superclass A::__sleep() method and 
join that with the new arrow.
However this is much cleaner code. And wether a member is transient or 
not should be declered nearby the member to keep else other developers 
may not now wether the member will be serialized or not.
 [2009-11-09 16:23 UTC]
Patch already exists, just need to discuss when is the correct time to add it.
 [2010-12-20 09:26 UTC]
-Package: Feature/Change Request +Package: *General Issues -Operating System: all +Operating System: * -PHP Version: 5CVS-2006-11-26 (CVS) +PHP Version: *
 [2015-06-23 21:06 UTC] chealer at gmail dot com
I think we should rather ease serialization customization. If we could simply adjust the object before serialization, use the default serialization, then adjust tje object after a default unserialization, we could solve this case by simply unsetting problematic properties before serialization.
 [2017-10-24 06:12 UTC]
-Status: Assigned +Status: Open -Assigned To: scottmac +Assigned To:
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 03:01:29 2019 UTC