From: iain at iaindooley dot com
Operating system: FreeBSD 6.0
PHP version: 5.1.2
PHP Bug Type: Class/Object related
Bug description: unserialize method is not called on an object when session is
restored
Description:
------------
when an object is stored in the session, serialize is called on that
object when the script finishes executing if that object implements
Serializable, but unserialize is not called when the session is reloaded
Reproduce code:
---------------
<?
class SomeClass implements Serializable
{
private $member;
public $another;
function SomeClass()
{
$this->member = 'member value';
$this->another = 'another value';
}
public function serialize()
{
echo('called serialize<br />');
}
public function unserialize($serialized)
{
echo('called serialize<br />');
}
}
class AnotherClass extends SomeClass
{
function AnotherClass()
{
$this->SomeClass();
}
}
$obj = new AnotherClass();
session_name('god');
session_start();
$_SESSION['var'] = $obj;
?>
Expected result:
----------------
called serialize
called unserialize
Actual result:
--------------
called serialize
--
Edit bug report at http://bugs.php.net/?id=36694&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36694&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36694&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36694&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36694&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36694&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36694&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36694&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36694&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36694&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36694&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36694&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36694&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36694&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36694&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36694&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36694&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36694&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36694&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36694&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36694&r=mysqlcfg