#23280 [Opn->Bgs]: exit; inside __wakeup() forgets changes to session vars
| From: | sniper@php.net | Date: | Mon, 21 Apr 2003 14:57:08 +0000 |
| Subject: | #23280 [Opn->Bgs]: exit; inside __wakeup() forgets changes to session vars | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37974@lists.php.net to get a copy of this message | ||
ID: 23280
Updated by: sniper@php.net
Reported By: adamh at densi dot com
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Linux 2.4.20
PHP Version: 4.3.0
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2003-04-19 12:08:39] adamh at densi dot com
<?php
class MyObj
{
var $p1;
function MyObj()
{
$this->p1 = "foo";
}
function __sleep()
{
return array("p1");
}
function __wakeup()
{
if (!isset($this->p1))
exit("No bug");
unset($this->p1);
header("Location: " . $_SERVER["PHP_SELF"]);
exit;
}
}
session_start();
if (!isset($_SESSION["obj"]) || !isset($_SESSION["obj"]->p1)) {
$_SESSION["obj"] =& new MyObj();
}
var_dump($_SESSION["obj"]);
?>
With the above code, the following "should" happen:
1. Browse to the page, it'll create the object and initialize p1, then
var_dump() it.
2. Refresh. Through __wakeup(), p1 should be unset and then it should
redirect.
3. (automatically redirected) __wakeup() should then run exit("No
bug");
What DOES happen:
In the second page, __wakeup() unsets p1 in a certain instance of the
object, but that instance isn't the same as the one in
$_SESSION["obj"]. Thus, the ACTUAL session object is not edited, and so
we get an infinite redirect.
The problem:
It must be that if __wakeup() doesn't return the session is not
updated. That's okay, I can live with that -- but at the very least,
that behavior should be documented. On the other hand, as far as I
know, it's a bug with PHP.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23280&edit=1