From:             peter dot evertz at snafu dot de
Operating system: Linux 2.6.18
PHP version:      5.2.4RC1
PHP Bug Type:     Session related
Bug description:  class member is broken after retrieving vom Session

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 bug report at http://bugs.php.net/?id=42239&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42239&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42239&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42239&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42239&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42239&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42239&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42239&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42239&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42239&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42239&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42239&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42239&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42239&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42239&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42239&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42239&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42239&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42239&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42239&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42239&r=mysqlcfg

Reply via email to