|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46451 Session module needs a hook into the evaluator
Submitted: 2008-11-01 14:19 UTC Modified: 2013-06-27 11:00 UTC
Avg. Score:3.2 ± 1.3
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jost_boekemeier at yahoo dot de Assigned:
Status: Analyzed Package: Scripting Engine problem
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jost_boekemeier at yahoo dot de
New email:
PHP Version: OS:


 [2008-11-01 14:19 UTC] jost_boekemeier at yahoo dot de
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:
  * 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");
if(!$a) {
  echo "new C\n";
  $a=new C();
echo "$a\n";
exit (0);

Expected result:
result code 0

Actual result:
result code 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-23 21:27 UTC]
-Package: Feature/Change Request +Package: Session related -PHP Version: 5.2.6 +PHP Version: *
 [2013-06-27 11:00 UTC]
-Status: Open +Status: Analyzed -Package: Session related +Package: Scripting Engine problem
 [2013-06-27 11:00 UTC]
Verified with PHP 5.4/5.5.

This is not a session problem, but a scripting engine.

__destruct() should be the last magic method to be called at shutdown. Is there 
any good reason for this behavior?
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC