Bug #52604 [Com]: Serialization of objects with __sleep() and fatal error
| From: | isaiah dot derosewilson at kohanaphp dot com | Date: | Tue, 14 Sep 2010 02:43:09 +0000 |
| Subject: | Bug #52604 [Com]: Serialization of objects with __sleep() and fatal error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154317@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52604&edit=1
ID: 52604
Comment by: isaiah dot derosewilson at kohanaphp dot com
Reported by: zerspam at mail dot ru
Summary: Serialization of objects with __sleep() and fatal
error
Status: Open
Type: Bug
Package: Session related
Operating System: irrelevant
PHP Version: Irrelevant
Block user comment: N
New Comment:
I also have this same problem. I've tested both php 5.2.12 and 5.3.3 and
neither of them correctly serialize the object when there is a fatal
error - the whole object gets serialized when there is a fatal error
instead of just the properties in __sleep(). However if your class
implements Serializable everything works as expected when there is a
fatal error.
Previous Comments:
------------------------------------------------------------------------
[2010-09-05 13:32:43] zerspam at mail dot ru
Well, 3 weeks left and even no comments from dev team?
------------------------------------------------------------------------
[2010-08-14 09:40:26] zerspam at mail dot ru
Description:
------------
Seems like __sleep() does not being invoked when fatal error was risen.
Test script:
---------------
set_error_handler('my_error_handler');
session_start();
$obj = new myclass();
$_SESSION['obj'] = $obj;
$a->b();
class myclass
{
private $a = 1;
private $b = 2;
public function __sleep()
{
return array('a');
}
}
function my_error_handler($code, $error, $file = NULL, $line = NULL)
{
throw new ErrorException($error, $code, 0, $file, $line);
}
Expected result:
----------------
Object with only 'a' property in session file
Actual result:
--------------
Object with 'a' and 'b' properties in session file
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52604&edit=1