From:             jost_boekemeier at yahoo dot de
Operating system: Any
PHP version:      5.2.6
PHP Bug Type:     Scripting Engine problem
Bug description:  Session module needs a hook into the evaluator

Description:
------------
If a PHP object is stored into the PHP session, __destruct() is called
before __sleep().

One way to fix this bug is to change the evaluator to call
session_write_close() before calling __destruct().





Reproduce code:
---------------
<?php
/**
  * Check if __destruct() is called after __sleep()
  * exit with 1 if the test failed.
  */
class C {
  var $destroyed = false;
  function __destruct() {
    echo "destroy called\n";
    $this->destroyed = true;
  }
  function __sleep() {
    if ($this->destroyed) {echo("sleep failed. bleh!\n"); exit(1); }
    return array();
  }
  function __wakeup() {
    $this->destroyed = false;
  }
  function __toString() {
    return "C::".($this->destroyed?"destroyed":"active");
  }
}
session_id("session-write-close-bug");
session_start();
[EMAIL PROTECTED]'a'];
if(!$a) {
  echo "new C\n";
  $a=new C();
  $_SESSION['a']=$a;
 }
$a=$_SESSION['a'];
echo "$a\n";
//session_write_close();
exit (0);
?>


Expected result:
----------------
result code 0

Actual result:
--------------
result code 1

-- 
Edit bug report at http://bugs.php.net/?id=46451&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46451&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46451&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46451&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46451&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46451&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46451&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46451&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46451&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46451&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46451&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46451&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46451&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46451&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46451&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46451&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46451&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46451&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46451&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46451&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46451&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46451&r=mysqlcfg

Reply via email to