From: Operating system: Windows XP SP2 PHP version: 5.2.13 Package: Session related Bug Type: Bug Bug description:Can't call userland functions from __sleep()
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 -- Edit bug report at http://bugs.php.net/bug.php?id=51630&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51630&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51630&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51630&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51630&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51630&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51630&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51630&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51630&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51630&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51630&r=support Expected behavior: http://bugs.php.net/fix.php?id=51630&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51630&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51630&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51630&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51630&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51630&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51630&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51630&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51630&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51630&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51630&r=mysqlcfg