php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51630 Can't call userland functions from __sleep()
Submitted: 2010-04-22 10:49 UTC Modified: 2010-06-18 15:23 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: peter dot dishman at telephoneticsvip dot co dot uk Assigned:
Status: Closed Package: Session related
PHP Version: 5.2.13 OS: Windows XP SP2
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: peter dot dishman at telephoneticsvip dot co dot uk
New email:
PHP Version: OS:

 

 [2010-04-22 10:49 UTC] peter dot dishman at telephoneticsvip dot co dot uk
Description:
------------
Prior to v5.2.10 you could call userland functions in the magic method 
__sleep(). Now in 5.2.10, .11, .12 and .13 I just get a fatal error undefined 
function when I try to do so.

I've tested this in 5.3.2 and it works correctly as it does in 5.2.9 and before.

This is running on the standard 5.2.13 TS VS6 build and my session configuration 
is: 
[Session]
session.save_handler = files
session.save_path = "c:/php/tmp"
session.use_cookies = 1
session.use_only_cookies = 1
session.name = sID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 1000
session.gc_maxlifetime = 9000
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = 
"a=href,area=href,frame=src,input=src,form=,fieldset=,iframe=src"

Test script:
---------------
<?php
function inc ($foo) {
	return ($foo + 1);
}

class foo {
	function __construct() {
		$this->bar = 0;
	}
	function __sleep() {
		$this->bar = inc($this->bar);
		return array('bar');
	}	
	public $bar;
}

session_start();
if (!isset($_SESSION['foo'])) {
	$_SESSION['foo'] = new foo();
}
$foo = $_SESSION['foo'];

echo "foo->bar = ".$foo->bar."<br>";
?>

Expected result:
----------------
As you refresh the page given by the script, you should just see the number 
increment each time with no errors generated.

Actual result:
--------------
In 5.2.13, after refreshing the page you get:
Fatal error: Call to undefined function inc() in C:\test\sleeptest.php on line 12 

This worked correctly in 5.2.9 and before, and also works in 5.3.2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-30 01:26 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2010-04-30 01:26 UTC] felipe@php.net
Please try using this snapshot:

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

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

I cannot reproduce it on 5.2.14-dev.
 [2010-05-01 15:31 UTC] peter dot dishman at telephoneticsvip dot co dot uk
-Status: Feedback +Status: Open
 [2010-05-01 15:31 UTC] peter dot dishman at telephoneticsvip dot co dot uk
There don't seem to be any snapshots available at that windows url?
 [2010-06-18 15:23 UTC] peter dot dishman at telephoneticsvip dot co dot uk
-Status: Open +Status: Closed
 [2010-06-18 15:23 UTC] peter dot dishman at telephoneticsvip dot co dot uk
I've tried this again, and it appears to be caused by apc. If I disable apc, the 
problem goes away.
I'm not on the latest version of apc so am closing this bug.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Dec 07 17:05:52 2022 UTC