|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2001-08-16 10:28 UTC] clownfighter at hotmail dot com
 When I create a db connection object, call it "conn", with a __sleep function to close the connection when the object is serialized for a session, any object which has an instance of "conn" fails to load properly. For instance, if I have an object "permissions" that has a "conn" object, when I unserialize "permissions" from a session the class appears to never be defined. I don't get any error messages until I try to use "permissions," in which case it says "Call to a function of a non-object" whenever I try to use a function of "permissions." Never do I get an error from "conn" or "permissions." Comment out the __sleep function in "conn" and things work fine. My configure line: './configure' '--with-postgres' '--with-gd' '--with-pspell' '--with-apxs' PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 21:00:02 2025 UTC | 
Confirm this bug on PHP 4.0.6 and 4.1.1 on Windows 2000 Server and Apache 1.3.23 Here is requested testcase: <?php class myClass { function myClass() { } function __sleep() { echo 'sleep!<br>'; } function __wakeup() { echo 'wakeup!<br>'; } }; $obj = new myClass(); $str = serialize($obj); echo $str."<br>"; $obj2 = unserialize($str); print_r($obj2); ?> Running this script on PHP 4.0.6 will set $str to empty string (however __sleep() is called properly). Commenting out __sleep() method will return normal serialized value of an object. Running this script on PHP 4.1.1 cause PHP to crash. Please reopen this bug or i'll submit new one :)I can reproduce the crash with the following backtrace: Starting program: /home/ek/projects/php/php4/sapi/cli/php -f ~/t sleep!<br> Program received signal SIGSEGV, Segmentation fault. 0x80dc1c8 in php_var_serialize (buf=0x7fffe3e0, struc=0x816c6ec, var_hash=0x7fffe3ec) at var.c:561 561 smart_str_0(buf); (gdb) bt #0 0x80dc1c8 in php_var_serialize (buf=0x7fffe3e0, struc=0x816c6ec, var_hash=0x7fffe3ec) at var.c:561 #1 0x80dc24f in zif_serialize (ht=1, return_value=0x81773ec, this_ptr=0x0, return_value_used=1) at var.c:583 #2 0x80f0ed1 in execute (op_array=0x81715d4) at ./zend_execute.c:1598 #3 0x807011c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at zend.c:810 #4 0x807d51f in php_execute_script (primary_file=0x7ffff8dc) at main.c:1377 #5 0x805ad89 in main (argc=3, argv=0x7ffff944) at php_cli.c:555