#36364 [NEW]: Setting a class variable as a reference to a session variable breaks

From: Date: Sat, 11 Feb 2006 00:26:34 +0000
Subject: #36364 [NEW]: Setting a class variable as a reference to a session variable breaks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93147@lists.php.net to get a copy of this message
From: andrew at andrewshell dot org Operating system: Windows and Linux PHP version: 4CVS-2006-02-11 (snap) PHP Bug Type: Session related Bug description: Setting a class variable as a reference to a session variable breaks 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 bug report at http://bugs.php.net/?id=36364&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36364&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36364&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36364&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36364&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36364&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36364&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36364&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36364&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36364&r=support Expected behavior: http://bugs.php.net/fix.php?id=36364&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36364&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36364&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36364&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36364&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36364&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36364&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36364&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36364&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36364&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36364&r=mysqlcfg

« previous php.bugs (#93147) next »