From:             thomas dot meike at nic dot at
Operating system: Linux Unix Windows
PHP version:      5.2.6
PHP Bug Type:     Arrays related
Bug description:  strange behaviour on saving arrays with moved cursors in 
Session 

Description:
------------
you define an array
step through ONLY SOME elements using list-each structure
stepping through you perform some changes on data
finishing the while-structure the array is saved in session
let's say, somewhere else in your businesslogic you need these session
data once more:
you initiate a variable with the recently saved session array 
the PROBLEM now: the variable is initiated with the array NOT RESETTED
as defined in documentation an array assigned to a variable has to be
resetted
the problem exists also with php version 5.2.5


Reproduce code:
---------------
session_start();                
$arrL =
array("test1","test2","test3","test4","test5","test6","test7","test8","test9","test10");
if(!isset($_SESSION['DATA'])){
        $_SESSION['DATA']=$arrL;
}
                        $counter = 3;
                        $arrSessData = $_SESSION['DATA'];
                        while((list($index, $value) = each($arrSessData)) && 
($counter > 0) )
{
                                $arrSessData[$index] =  '_test_' . $value;
                                $counter--;
                        }
                        //store changes in session
                        $_SESSION['DATA']=$arrSessData;
                        //somewhere else within the businesslogic, init local 
variable and step
through
                        $arrSessDataProc = $_SESSION['DATA'];
                        while((list($index, $value) = each($arrSessDataProc)) ){
                                echo "<br>" . $index . ' ' . $value;
                        }


Expected result:
----------------
0 _test_test1
1 _test_test2
2 _test_test3
3 test4
4 test5
5 test6
6 test7
7 test8
8 test9
9 test10

Actual result:
--------------
4 test5
5 test6
6 test7
7 test8
8 test9
9 test10

-- 
Edit bug report at http://bugs.php.net/?id=45369&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45369&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45369&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45369&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45369&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45369&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45369&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45369&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45369&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45369&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45369&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45369&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45369&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45369&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45369&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45369&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45369&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45369&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45369&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45369&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45369&r=mysqlcfg

Reply via email to