#35511 [NEW]: Unserialized global arrays do not globalize in functions properly.
From: ngaugler at ngworld dot net
Operating system: Linux 2.6
PHP version: 4.4.1
PHP Bug Type: Scripting Engine problem
Bug description: Unserialized global arrays do not globalize in functions properly.
Description:
------------
In 4.4.1, when you unserialize an array, then attempt to globalize it
within a function, and then pass it to an internal array function such as
next or key, it does not work as it was in 4.3.10 or how it functions in
PHP 5.0.5. This functions as expected in 4.3.10 and 5.0.5. The
documentation clearly states you are not to use next(&array) or
key(&array) when using references, which is why this is not used.
Reproduce code:
---------------
<?
$ar = array(array('ID' => 'BOB'), array('ID' =>
'GEORGE'), array('ID' =>
'JOHN'));
$ser = serialize($ar);
$arn = unserialize($ser);
print_r($arn) . "\n\n";
function breakPHP() {
global $arn;
for ($i = 0, reset($arn); ($key = key($arn)), (isset($key));
next($arn), $i++) {
print "$key ... " . $arn[$key]['ID'] . "<br>\n";
if ($i > 5) {
print "we looped";
exit;
}
}
}
breakPHP();
?>
Expected result:
----------------
Array
(
[0] => Array
(
[ID] => BOB
)
[1] => Array
(
[ID] => GEORGE
)
[2] => Array
(
[ID] => JOHN
)
)
0 ... BOB<br>
1 ... GEORGE<br>
2 ... JOHN<br>
Actual result:
--------------
Array
(
[0] => Array
(
[ID] => BOB
)
[1] => Array
(
[ID] => GEORGE
)
[2] => Array
(
[ID] => JOHN
)
)
0 ... BOB<br>
0 ... BOB<br>
0 ... BOB<br>
0 ... BOB<br>
0 ... BOB<br>
0 ... BOB<br>
0 ... BOB<br>
--
Edit bug report at http://bugs.php.net/?id=35511&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35511&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35511&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35511&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35511&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35511&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35511&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35511&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35511&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35511&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35511&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35511&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35511&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35511&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35511&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35511&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35511&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35511&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35511&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35511&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35511&r=mysqlcfg
Thread (4 messages)
- ngaugler at ngworld dot net