ID: 42239
Updated by: [EMAIL PROTECTED]
Reported By: peter dot evertz at snafu dot de
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Linux 2.6.18
PHP Version: 5.2.4RC1
New Comment:
Objects of internal classes can't be serialized and therefore can't be
stored in a session. You might use __sleep/__wakeup magic methods to
store the timestamp in the session and then restore it.
Previous Comments:
------------------------------------------------------------------------
[2007-08-08 00:02:23] peter dot evertz at snafu dot de
Description:
------------
I found this while using propel. It uses DateTime class for storing.
After retrieving the class from a Session the member is broken.
The code creates a session variabel "v" with the given class if not
found.On the second call to the script the class is retrievies from
session. The member x is broken.
Reproduce code:
---------------
<?php
class c {
protected $v;
function print_type() {
if ( $this->v instanceof DateTime ) {
print "x is DateTime\n";
}
}
function get_v() {
return $this->v;
}
function set_v($i) {
$this->v=$i;
}
}
session_start();
if ( !isset($_SESSION["x"] )) {
$x = new c();
$x->set_v( new DateTime());
$_SESSION["x"]=$x;
print "New object created\n";
}
$_SESSION["x"]->print_type();
print $_SESSION["x"]->get_v()->format("d.m.Y");
?>
Expected result:
----------------
First call:
New object created x is DateTime 08.08.2007
Second call:
x is DateTime 08.08.2007
Actual result:
--------------
First call:
New object created x is DateTime 08.08.2007
Second call:
x is DateTime Warning: DateTime::format(): The DateTime object has not
been correctly initialized by its constructor in
/home/peter/workspace/Kurse/html/t1.php on line 28
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42239&edit=1