PHP 4.0 Bug #7291 Updated: Session drop objects in 4.0.3, it works OK in 4.0.2
| From: | david at boe dot es | Date: | Tue, 17 Oct 2000 19:29:39 +0000 |
| Subject: | PHP 4.0 Bug #7291 Updated: Session drop objects in 4.0.3, it works OK in 4.0.2 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-35317@lists.php.net to get a copy of this message | ||
ID: 7291
User Update by: david@boe.es
Status: Open
Bug Type: *Session related
Description: Session drop objects in 4.0.3, it works OK in 4.0.2
This script shows the behaviour:
<?
class Cart {
var $items; /* array de articulos */
function Cart() {
/* object constructor */
$this->init();
}
function init() {
/* inicializa y resetea la cesta */
$this->items = array();
}
function add($productid, $qty) {
/* aM-qade un articulo a la cesta aM-qadiendo el numero de unidades*/
if (isset($productid)) {
if (! isset($this->items[$productid])) {
$this->items[$productid]=0;
}
$this->items[$productid] += $qty;
}
}
}
session_start();
session_register("SESSION");
if (! isset($SESSION)) {
$SESSION = array();
}
if (! isset($SESSION["cesta"])) { // This is supposed to be executed
echo "INITIALIZING CART<BR>\n"; // just 1 time in the session,
$SESSION["cesta"] = new Cart; // isn't it?
}
$SESSION["cesta"]->add('cameras',1); // Add 1 to the 'cameras'
item
echo "Cameras: ";
echo $SESSION["cesta"]->items['cameras'];
echo "\n";
?>
When executed with PHP 4.0.2 it increments the counter for the 'cameras' item in the items
array of the 'cesta' object.
when executed with PHP 4.0.3 (or 4.0.3pl1), it always resets the counter and prints the
"Initializing object" message.
Thanks for your help, and congratulations for your work...
BTW, any1 going to ApacheCON next week?
Previous Comments:
---------------------------------------------------------------------------
[2000-10-17 14:37:50] david@boe.es
The session funtionality drops any object type variables when accesed in the page. If the page
doesn't access the object var, it doesn't deletes the object from the session file.
This behaviour began in 4.0.3 and is maintained in 4.0.3pl1. Reverting to 4.0.2 solves the problem.
I can't post the code, because it's too long, but I can work in a little script that
reproduce the problem if you really need it.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7291