Bug #60879 [Opn->Fbk]: unserialize() Does not invoke __wakeup() on object

From: Date: Thu, 26 Jan 2012 10:14:20 +0000
Subject: Bug #60879 [Opn->Fbk]: unserialize() Does not invoke __wakeup() on object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-166811@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60879&edit=1

 ID:                 60879
 Updated by:         johannes@php.net
 Reported by:        thijsputman at gmail dot com
 Summary:            unserialize() Does not invoke __wakeup() on object
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Windows 7
 PHP Version:        5.4.0RC6
 Block user comment: N
 Private report:     N

 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Works for me with latest svn. Do you have any special extension loaded or some special
configuration?


Previous Comments:
------------------------------------------------------------------------
[2012-01-25 13:24:57] thijsputman at gmail dot com

Description:
------------
When serializing/unserializing an object that contains both a __sleep() and __wakeup() method,
serialize() invokes the __sleep() method, but unserialize() does *not* invoke the __wakeup() method.

Using PHP 5.4.0RC6 (x86 NTS) on Windows 7, previously used 5.4.0RC5 which did not exhibit this
problem. See the below test script for an example (which works as expected in RC5, but not in RC6).

Test script:
---------------
class Woei{

	public function __sleep(){

		echo 'sleep' . PHP_EOL;

		return array();
	}

	public function __wakeup(){

		echo 'wakeup' . PHP_EOL;
	}
}

$Woei = new Woei();

$s1 = serialize($Woei);
$Woei2 = unserialize($s1);

$s2 = serialize($Woei2);
$Woei3 = unserialize($s2);

Expected result:
----------------
sleep
wakeup
sleep
wakeup

Actual result:
--------------
sleep
sleep


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60879&edit=1


Thread (14 messages)

« previous php.bugs (#166811) next »