PHP 4.0 Bug #7558: session - objects in arrays
| From: | info at borderblue dot com | Date: | Wed, 01 Nov 2000 00:51:37 +0000 |
| Subject: | PHP 4.0 Bug #7558: session - objects in arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-36566@lists.php.net to get a copy of this message | ||
From: info@borderblue.com
Operating system: Red Hat Linux 6
PHP version: 4.0.3pl1
PHP Bug Type: *Session related
Bug description: session - objects in arrays
I'm using php.ini-optimized with register_globals = Off, so I access session variables using
$HTTP_SESSION_VARS["blah"]. This is defined as an array of objects. I'm able to
access properties such as $HTTP_SESSION_VARS["blah"][0]->property, but I can't run
methods by doing $HTTP_SESSION_VARS["blah"][0]->method(). The following test script
illustrates the problem, reloading the page should increase the array size of "blah" each
time. I found that I could work around the problem by copying the session variable to a local
variable, doing the methods on that, and then copying back. I compiled PHP as a dynamic DSO module
using:
./configure --with-mysql --with-apxs=/usr/local/apache/bin/apxs
Here is the test script:
/* reload the page to increase the array size of "blah" */
class Test {
var $item;
function run() {
$this->item = 1234;
}
}
session_start();
session_register("blah");
if (!isset($HTTP_SESSION_VARS["blah"])) {
$HTTP_SESSION_VARS["blah"] = array();
}
echo "array size before =
",sizeof($HTTP_SESSION_VARS["blah"]),"<br>n";
$S = sizeof($HTTP_SESSION_VARS["blah"]);
$HTTP_SESSION_VARS["blah"][$S] = new Test;
/** this doesn't work *******************/
// $HTTP_SESSION_VARS["blah"][$S]->run();
/****************************************/
/** this works **************************/
$SESSION = $HTTP_SESSION_VARS;
$SESSION["blah"][$S]->run();
$HTTP_SESISON_VARS = $SESSION;
/****************************************/
echo "array size after =
",sizeof($HTTP_SESSION_VARS["blah"]),"<br>n";
--
Edit Bug report at: http://bugs.php.net/?id=7558&edit=1