Req #39635 [Asn->Opn]: Better control for serialization (keyword for permit property serialization)
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 06:12:36 +0000 |
| Subject: | Req #39635 [Asn->Opn]: Better control for serialization (keyword for permit property serialization) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211976@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39635&edit=1
ID: 39635
Updated by: kalle@php.net
Reported by: t dot prochazka at centrum dot cz
Summary: Better control for serialization (keyword for permit
property serialization)
-Status: Assigned
+Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: *
PHP Version: *
-Assigned To: scottmac
+Assigned To:
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2015-06-23 21:06:40] 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.
------------------------------------------------------------------------
[2009-11-09 16:23:56] scottmac@php.net
Patch already exists, just need to discuss when is the correct time to add it.
http://whisky.macvicar.net/patches/php-transient.diff.txt
------------------------------------------------------------------------
[2009-11-09 15:53:54] tjerkw at gmail dot com
Using a transient keyword is better because if we have the following
case:
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.
------------------------------------------------------------------------
[2007-01-25 15:54:50] 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 ...
------------------------------------------------------------------------
[2006-11-26 11:40:40] t dot prochazka at centrum dot cz
Description:
------------
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?
Example:
class Foo {
public $a;
public transient $b;
}
Description of Java transient keyword:
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#78119
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39635&edit=1