Date: 10/31/00
- Next message: sniper <email protected>: "[PHP-DEV] PHP 4.0 Bug #6764 Updated: ldap_search warning message"
- Previous message: Michael Youngstrom: "RE: [PHP-DEV] PHP 4.0 Bug #6529 Updated: Problems with $this in class constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: info <email protected>
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-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: sniper <email protected>: "[PHP-DEV] PHP 4.0 Bug #6764 Updated: ldap_search warning message"
- Previous message: Michael Youngstrom: "RE: [PHP-DEV] PHP 4.0 Bug #6529 Updated: Problems with $this in class constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

