#23195 [Ver->Bgs]: Use of $_POST/$_SESSION causes a endless loop
| From: | iliaa@php.net | Date: | Fri, 25 Apr 2003 00:49:05 +0000 |
| Subject: | #23195 [Ver->Bgs]: Use of $_POST/$_SESSION causes a endless loop | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-38343@lists.php.net to get a copy of this message | ||
ID: 23195
Updated by: iliaa@php.net
Reported By: jc at mega-bucks dot co dot jp
-Status: Verified
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Red Hat Linux 8.0
PHP Version: 4.3.2RC1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When you assign the array to another variable the internal array
position pointer gets reset. Which causes you loop which depends on the
array position to loop indefinately.
Use foreach() or a for() loop.
Previous Comments:
------------------------------------------------------------------------
[2003-04-18 21:19:43] iliaa@php.net
Here is a shorter example that demonstrates the problem:
<?php
$arr = array('a', 'b');
while (each($arr)) $arr2 = $arr;
?>
------------------------------------------------------------------------
[2003-04-14 01:15:09] jc at mega-bucks dot co dot jp
The following piece of code never terminates:
<?php
while (list($k, $v) = each( $_POST )) {
if(strstr($k, "CHANGE_DEL_DATES")) {
session_set_post_vars( $_POST );
}
}
function session_set_post_vars($post) {
$_SESSION["S_POST_VALUES"] = $post;
}
?>
The contents of the $_POST superglobal were:
Array
(
[CURRENT_DEL_METHOD] => YAMATO
[DEL_YEAR1] => 2003
[DEL_MONTH1] => 04
[DEL_DAY1] => 12
[ptime1] => 1
[DEL_YEAR2] => 2003
[DEL_MONTH2] => 04
[DEL_DAY2] => 12
[DEL_YEAR3] => 2003
[DEL_MONTH3] => 04
[DEL_DAY3] => 12
[DELIVER_ANYDAY] => on
[CHANGE_DEL_DATES_x] => 14
[CHANGE_DEL_DATES_y] => 7
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23195&edit=1