|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-28 20:58 UTC] thekid@php.net
Description:
------------
In 5.4.0RC6, a __wakeup() method is no longer called during unserialization.
Test script:
---------------
$ php -r 'class A { function __sleep() { echo "SLEEP\n"; return array(); } function __wakeup() { echo "WAKEUP"; }} $a= unserialize(serialize(new A()));'
Expected result:
----------------
SLEEP
WAKEUP
object(A)#1 (0) {
}
Actual result:
--------------
SLEEP
object(A)#1 (0) {
}
Patchesinit-serialize-levels.diff (last revision 2012-02-05 14:03 UTC by thekid@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 08:00:02 2025 UTC |
I can't actually reproduce this in the current 5.4 code: % php --version PHP 5.4.0RC7-dev (cli) (built: Jan 28 2012 13:21:30) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies % php -r 'class A { function __sleep() { echo "SLEEP\n"; return array(); } function __wakeup() { echo "WAKEUP"; }} $a= unserialize(serialize(new A()));' SLEEP WAKEUPI can also not reproduce the issue if I compile PHP myself, neither on Linux nor on Windows. From looking at the diffs between 5.4.0RC5 and current SVN, BG(serialize_lock) in conjunction with BG(unserialize).level and BG(serialize).level) sticks out. The thing I think is suspicous here is that BG(unserialize).level gets assigned to 1 inside a block guarded by if (... || !BG(unserialize).level) {, but is never assigned to 0. Are we running into this problem because BG(unserialize).level doesn't properly get initialized? I'm not an expert here but is it safe to rely on the compiler doing thos? Same goes for BG(serialize).level, by the way.