php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63224 error in __sleep whit reference to other classes
Submitted: 2012-10-05 15:56 UTC Modified: 2013-02-18 00:36 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: gabrielnn77 at gmail dot com Assigned:
Status: No Feedback Package: APC (PECL)
PHP Version: 5.4.7 OS: linux
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:
Package:
Bug Type:
Summary:
From: gabrielnn77 at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-05 15:56 UTC] gabrielnn77 at gmail dot com
Description:
------------
APC 3.1.13
the script fail to find class constant in the sleep method (fail in the second excecution )
error:
  
 PHP Fatal error:  Undefined class constant 'A_CONSTANT' in /home/var/www/html/tmp/apc_test.php on line 23


Test script:
---------------
session_start();


class A{
	public $b;
	
	public function __sleep(){
		$this->b->f();
		return array('b');
	}
}


class B{
	const A_CONSTANT = 1;
	public $var;

	public function f(){
		$this->var = self::A_CONSTANT;
	}
}


if(isset($_SESSION['lalala'])){
	echo "<pre>";
	$a = $_SESSION['lalala'];
	print_r($a);
}

//	another file
//	class A and B use autoload
$b = new B();
$a = new A();
$a->b = $b;

$_SESSION['lalala'] = $a;



Expected result:
----------------
no error

Actual result:
--------------
 PHP Fatal error:  Undefined class constant 'A_CONSTANT' in /home/var/www/html/tmp/apc_test.php on line 23


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-05 21:54 UTC] gopalv@php.net
This is highly likely due to the session handler being called after APC mops up 
the classes.

Can you try adding a session_write_close() at the end of the script?
 [2012-10-10 14:06 UTC] gabrielnn77 at gmail dot com
yes, this works
I have another error, but I do not know whether to the APC module, or if it is related to this solution

PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 
'Error at offset 1923 of 38785 bytes' in ....
Stack trace:
#0 [internal function]: ArrayIterator->unserialize('x:i:0;a:10:{i:0...')
....

the error occurs randomly, and I could not detect that is what produces
 [2012-12-05 14:45 UTC] ab@php.net
Automatic comment from SVN on behalf of ab
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328683
Log: added a test for bug #63224
 [2012-12-05 15:00 UTC] ab@php.net
I can't repro the latter error using apc trunk and php 5.4.9, most likely it's not APC related. Could you test again? Also i've added your test code to tests/bug63224.phpt, would be useful if you'd run it in your environment.
 [2012-12-05 15:00 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2013-02-18 00:36 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Dec 07 22:03:34 2021 UTC