PHP 4.0 Bug #7557 Updated: Array stored in session loose content

From: Date: Sat, 04 Nov 2000 00:32:58 +0000
Subject: PHP 4.0 Bug #7557 Updated: Array stored in session loose content
Groups: php.dev 
Request: Send a blank email to php-dev+get-37057@lists.php.net to get a copy of this message
ID: 7557 Updated by: waldschrott Reported By: twoerner@redhat.de Status: Feedback Bug Type: *Session related Assigned To: Comments: works for me (4.0.4dev), please try 4.0.4 as far as it is out and report results Previous Comments: --------------------------------------------------------------------------- [2000-11-02 03:09:55] twoerner@redhat.de Every call to the update function in the session class appends a new C_CART_ITEM with the actual time to the cart1 and cart2 arrays. If you reload the page several times, you get the following: SESSION-ID: 970efca9d3effdadf14e679d0e88b349 ITEMS: 973150040 : 1 973150036 : 8 : 1 973150038 : 7 : 1 973150039 : 6 : 1 973150039 : 5 : 1 973150039 : 4 : 1 973150040 : 3 : 1 973150040 : 2 : 1 973150040 : 1 The left two rows show the content of cart1 and the right 2 rows the content of cart2. Both arrays should have the same content. cart1 is referenced by item in the show function. And when this is done, this entry is not available in the next page (after reload etc.). cart2 is referenced as the whole array - this works. This bug occurs with PHP versions > 4.0.3 (4.0.2 not tested). It works fine with version 4.0.1pl1 . --------------------------------------------------------------------------- [2000-10-31 18:00:18] twoerner@redhat.de <? class C_CART_ITEM { var $pid; var $id=0; Function C_CART_ITEM() { } } class C_SESSION { var $cart1 = array(); var $cart2 = array(); Function C_SESSION() { } Function update() { $item = new C_CART_ITEM(); $item->pid = "".time(); array_push($this->cart1, $item); array_push($this->cart2, $item); } Function show() { echo("ITEMS:<BR><TABLE CELLSPACING=2 CELLPADDING=0>"); $i = 0; while ($i < MAX(count($this->cart1),count($this->cart2))) { $item = &$this->cart1[$i]; $item->id += 1; echo("<TR><TD>".$item->pid." : ".$item->id."</TD>"); $item = &$this->cart2; $item[$i]->id += 1; echo("<TD>".$item[$i]->pid." : ".$item[$i]->id."</TD</TR>"); $i++; } echo("</TABLE><P>"); } } session_start(); if (!$session) { $session = new C_SESSION(); session_register("session"); } else $session->update(); echo "SESSION-ID: ".session_id()."<BR>"; $session->show(); ?> --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7557

« previous php.dev (#37057) next »