#36364 [Opn->Bgs]: Setting a class variable as a reference to a session variable breaks
| From: | andrew at andrewshell dot org | Date: | Sat, 11 Feb 2006 00:34:08 +0000 |
| Subject: | #36364 [Opn->Bgs]: Setting a class variable as a reference to a session variable breaks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-93148@lists.php.net to get a copy of this message | ||
ID: 36364
User updated by: andrew at andrewshell dot org
Reported By: andrew at andrewshell dot org
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Windows and Linux
PHP Version: 4CVS-2006-02-11 (snap)
New Comment:
Seems the servers it breaks on are with register_globals on it works
with register_globals off. So it makes sense now.
Previous Comments:
------------------------------------------------------------------------
[2006-02-11 01:26:33] andrew at andrewshell dot org
Description:
------------
I'm trying to use a session variable in a class as a singleton. If the
session var doesn't exist I create it as an empty array. Once it exists
I assign it by reference to a class variable. The functions of the
class reference the class variable. Since the class variable is a
reference to the session variable the class variable should exist
between page refreshes. This works sometimes. On some server/php
configurations it always works on others it always breaks. If the
session variable key is named the same as the class name it breaks. If
it's a random string it works.
Might be related to Bug #28144 but that was fixed in 4.3.6 and this is
broken seemingly with 4.4.0 and later.
Here are configurations that work and ones that break:
Breaks on:
Microsoft-IIS/6.0 as ASAPI with PHP 4.4.0
Microsoft-IIS/5.1 as CGI/FastCGI with PHP 4.4.1 and 4.4.2
Apache/1.3.33 as CGI with PHP 4.4.2
Microsoft-IIS/5.1 as CGI/FastCGI with 4.4.x-dev snapshot 2/10/2006
Works correctly on
Microsoft-IIS/6.0 as CGI/FastCGI with PHP 4.3.6
Apache/1.3.34 as Module with PHP 4.4.2
Reproduce code:
---------------
http://andrewshell.org/test.php <-- Shows the error
http://andrewshell.org/test.phps <-- source code
First time you hit the page it works with 1 value set to each instance
of the code. If you hit refresh the first two break and the third one
works.
Expected result:
----------------
All three instances should behave in the same way with results after
several refreshes looking like:
Array
(
[0.20239000 1139615291] => 5
[0.46027100 1139615292] => 7
[0.50540700 1139616583] => 0
[0.31605700 1139616584] => 2
[0.59282400 1139616649] => 6
)
Actual result:
--------------
The first two instances (blah and blah2) return with:
Warning: Cannot use a scalar value as an array in
/home/.untouchables/shellab/andrewshell.org/test.php on line x
blah Object
(
[data] => blah Object
(
[data] => *RECURSION*
)
)
after the first refresh.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36364&edit=1