php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60879 unserialize() Does not invoke __wakeup() on object
Submitted: 2012-01-25 13:24 UTC Modified: 2012-02-28 13:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thijsputman at gmail dot com Assigned: pajoye (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.0RC6 OS: Windows 7
Private report: No CVE-ID: None
 [2012-01-25 13:24 UTC] 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

Patches

pragmaoptoff (last revision 2012-02-20 10:53 UTC by pajoye@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-26 10:14 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2012-01-26 10:14 UTC] johannes@php.net
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?
 [2012-01-26 10:56 UTC] thijsputman at gmail dot com
-Status: Feedback +Status: Open
 [2012-01-26 10:56 UTC] thijsputman at gmail dot com
Just tried with revision 322785 and it indeed works as expected.

To assert my sanity I re-downloaded 5.4.0RC6 (VC9 x86 Non Thread Safe, 2012-Jan-19 23:40:07) from the QA website and in that release the problem does exist.
 [2012-01-26 11:33 UTC] johannes@php.net
So let's assume this was fixed. I can't see a relevant change for this, though. There will be another RC soon, an you check that, too, to be safe? Thanks :-)
 [2012-01-26 11:33 UTC] johannes@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: johannes
 [2012-02-06 13:44 UTC] yoozer at gmail dot com
I've just tested the official release of RC7; it still exhibits this issue with exactly the same testcase.
 [2012-02-08 13:46 UTC] thijsputman at gmail dot com
-Status: Closed +Status: Assigned
 [2012-02-08 13:46 UTC] thijsputman at gmail dot com
Just tried with RC7 (VC9 x86 Non Thread Safe - 2012-Feb-06 23:40:37) and the problem has reappeared...
 [2012-02-08 14:02 UTC] thijsputman at gmail dot com
The configure commands between RC7-dev (which works properly) and RC7 (which exhibits the problem) seem to differ a bit, could that be the cause?

RC7 contains the following elements not contained in RC7-dev:
--disable-nsapi --with-enchant=shared --disable-static-analyze --with-pgo

RC7-dev contains the following not contained in RC7:
--enable-object-out-dir=d:/temp/obj/nts-windows-vc9-x86

Also, there seems to be a small typo in the RC7-dev configure command:
"--enable-snapshot-build --disable-zts --disable-isapi --enable-debug-pack --disable-isapi" 

ISAPI is disabled twice (I'm guessing the second one should be nsapi?)
 [2012-02-10 22:43 UTC] johannes@php.net
-Assigned To: johannes +Assigned To: szarkos
 [2012-02-10 22:43 UTC] johannes@php.net
Steve,

I can't verify the report on Linux and don't see a related code-change. As I don't have a proper Windows environment at hand: From the report the user gave it seems like the compiler would do some over-optimistic optimization, can you take a look into this?

Also please mind the notes on the other small issues in the configure lines.
 [2012-02-17 18:05 UTC] szarkos@php.net
Thank you for reporting this!  It appears to be related to the PGO build, however we've been using PGO since RC3, so it looks like this popped up in the RC6+ builds.

Can you please test this build of RC8 and let me know if it fixes the issue in your environment:  http://windows.php.net/downloads/snaps/ostc/build/php-5.4.0-RC8-1/php-5.4.0RC8-nts-Win32-VC9-x86.zip

The configure line was fixed earlier (was also in some 5.3 snaps), good catch.  It does not appear to be related to this issue, however.
 [2012-02-20 09:58 UTC] thijsputman at gmail dot com
The RC8 build provided fixes the issue in my environment.

Thanks for the quick follow up!
 [2012-02-20 10:53 UTC] pajoye@php.net
The following patch has been added/updated:

Patch Name: pragmaoptoff
Revision:   1329735212
URL:        https://bugs.php.net/patch-display.php?bug=60879&patch=pragmaoptoff&revision=1329735212
 [2012-02-23 19:31 UTC] szarkos@php.net
-Status: Assigned +Status: Closed
 [2012-02-23 19:40 UTC] pajoye@php.net
-Status: Closed +Status: Assigned -Assigned To: szarkos +Assigned To: pajoye
 [2012-02-23 19:40 UTC] pajoye@php.net
Assigned to me, have to apply the patch to 5.4+
 [2012-02-28 13:58 UTC] pajoye@php.net
-Status: Assigned +Status: Closed
 [2012-02-28 13:58 UTC] pajoye@php.net
This bug has been fixed in SVN.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-02-28 18:36 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=323633
Log: - fix bug #60879, unserialize does not invoke __wakeup
 [2012-04-18 09:45 UTC] laruence@php.net
Automatic comment on behalf of pajoye
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f44bf55558944b573b8e215d1d616714f5b65850
Log: - fix bug #60879, unserialize does not invoke __wakeup
 [2012-07-24 23:37 UTC] rasmus@php.net
Automatic comment on behalf of pajoye
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f44bf55558944b573b8e215d1d616714f5b65850
Log: - fix bug #60879, unserialize does not invoke __wakeup
 [2013-11-17 09:33 UTC] laruence@php.net
Automatic comment on behalf of pajoye
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f44bf55558944b573b8e215d1d616714f5b65850
Log: - fix bug #60879, unserialize does not invoke __wakeup
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC