|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59112 Late static binding and serializing with sessions causes errors
Submitted: 2010-03-13 03:23 UTC Modified: 2010-03-19 17:23 UTC
From: josh dot varner at gmail dot com Assigned:
Status: Duplicate Package: APC (PECL)
PHP Version: 5.3.1 OS: Mac OS X 10.6.2
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: josh dot varner at gmail dot com
New email:
PHP Version: OS:


 [2010-03-13 03:23 UTC] josh dot varner at gmail dot com
Using: APC from Subversion (checked out on 2010-03-13, 
revision #296139) with PHP 5.3.1

I'm getting a fatal error when using late static binding 
features within a serialize() function for storing an object 
in a session.  I'm not familiar with the internals of this, 
so the fact that it's happening within the serialize() call 
may be irrelevant.

If I remove the APC extension from php.ini, I do not receive 
any errors-- the code behaves as expected.

I based this sample code on the following but, which I found 
while trying to troubleshoot this.

Reproduce code:

class One implements Serializable {
	protected static $var;

	public static function getVar() {
		return static::$var;
	public function serialize() {
	    return serialize(array('var' => static::getVar()));
	public function unserialize($str) {
	    $data = unserialize($str);

class Two extends One {
	public static $var = 'two';



$_SESSION['blah'] = new Two();

Expected result:
View #1: var_dump output empty, nothing else
View #2 and on: var_dump output should show simple dump of the 
Two object.

Actual result:
View #1: fine
View #2: fine
View #3: The following:

array(1) { ["blah"]=> object(Two)#1 (0) { } } 
Fatal error: Access to undeclared static property: Two::$var 
in /webroot/apc_test.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-19 17:23 UTC] josh dot varner at gmail dot com
Apologies-- I finally tracked down the cause of this bug, 
which is related to the shutdown sequence and such.  Calling 
session_write_close() explicitly seems to fix this, though I 
really hope that this is addressed in the future.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 19:01:33 2024 UTC