ID: 20728 Comment by: alex at avannaproductions dot com Reported By: mikemc-phpbug at contactdesigns dot com Status: No Feedback Bug Type: Session related Operating System: Linux 2.4.x PHP Version: 4.2.3 New Comment:
I'm experiencing this problem with 4.3. I did a global find and replace across many php files to change $HTTP_SESSION_VARS to $_SESSION. Then I went through and removed all the functions (like session_register) that are no longer needed. The one thing I FORGOT to remove was the line "global $HTTP_SESSION_VARS" each time it appeared. Instead my find and replace just changed it to "global $_SESSION". Seems to me that the line "global $_SESSION" should be ignored by PHP since it is redundant, rather than preventing values from being set. It could at least give a warning but still work. Perhaps that is the best method since it might prevent a script from breaking, yet still alert the developer he/she is doing something wrong. Previous Comments: ------------------------------------------------------------------------ [2002-12-15 04:04:46] [EMAIL PROTECTED] No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2002-12-01 19:48:10] [EMAIL PROTECTED] I still don't see any bug here..using references with _SESSION is not really useful as only the value is stored.. You think it should stay as a reference? ------------------------------------------------------------------------ [2002-12-01 19:06:00] mikemc-phpbug at contactdesigns dot com Hello, This code is incorrect - I must have pasted over the code after I modified it during testing as $foobar is not a reference, but a copy. Here is what it should be (please note that you will have to hit reload after the first hit as session gets created on the first hit - so load it and hit reload - and then view the output): <?php session_start(); echo 'Before session modifications:<br><pre>'; var_dump($_SESSION); $_SESSION['foobar'] = 1; $foobar =& $_SESSION['foobar']; global $foobar; $foobar = 3; echo '</pre>After session modifications:<br><pre>'; var_dump($_SESSION); ?> ------------------------------------------------------------------------ [2002-12-01 16:13:01] [EMAIL PROTECTED] I get this normal output: Before session modifications: array(1) { ["foobar"]=> int(1) } After session modifications: array(1) { ["foobar"]=> int(1) } No bug here. (using PHP 4.3.0-dev) ------------------------------------------------------------------------ [2002-12-01 16:07:16] mikemc-phpbug at contactdesigns dot com Hello, I don;t think it is quote as easy as saying "Don't use global with the autoglobal arrays.". Please read my original bug post. I went out of my way to be very detailed so that I don't waste your time - this does nobody any good though if you don't take the time to read it. More specifically, this is the part I am referring to: <ORIGNAL BUG POST> So now you are asking that is interesting, but why would you ever want to "global" an autoglobal. Good question! There would be no purpose in doing this since $_SESSION is always in scope. Well, this bug presented itself to me in an application where there was a reference to a portion of $_SESSION. Since the application is over 5000 lines of code, we will view a highly condensed test version of this: <?php session_start(); echo 'Before session modifications:<br><pre>'; var_dump($_SESSION); $_SESSION['foobar'] = 1; $foobar = $_SESSION['foobar']; global $foobar; $foobar = 3; echo '</pre>After session modifications:<br><pre>'; var_dump($_SESSION); ?> </ORIGNAL BUG POST> So the bug presents itself when you "global" a reference to an array element of an autoglobal as well. Perhaps, I should have used this as the original code example. Please take the time to read the full bug post. Thank You, Mike ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/20728 -- Edit this bug report at http://bugs.php.net/?id=20728&edit=1