From: php_bug dot email at email dot digiways dot com
Operating system: Windows XP
PHP version: 5.1.6
PHP Bug Type: Arrays related
Bug description: foreach($_GET as $key => &$value) causes later bugs passing
$_GET as a paramete
Description:
------------
if we iterate over $_GET using references (see the example) and pass $_GET
to a function, function modifies $_GET and not the local copy.
For example, save the example code in test.php and open
test.php?mykey=foo
.
Reproduce code:
---------------
<?php
function doit($http_get_params)
{
$http_get_params['mykey'] = 'bar';
echo '<br/>'.$_GET['mykey'];
}
foreach($_GET as $key => &$value) {}
echo '<br/>'.$_GET['mykey'];
doit($_GET);
echo '<br/>'.$_GET['mykey'];
?>
Expected result:
----------------
When we open test.php?mykey=foo I expect to see
foo
foo
foo
Actual result:
--------------
When we open test.php?mykey=foo we actually see
foo
bar
bar
--
Edit bug report at http://bugs.php.net/?id=39011&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39011&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39011&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39011&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39011&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39011&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39011&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39011&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39011&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39011&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39011&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39011&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39011&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39011&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39011&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39011&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39011&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39011&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39011&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39011&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39011&r=mysqlcfg