From: watermark86 at gmail dot com
Operating system: ubuntu 8.04
PHP version: 5.2.6
PHP Bug Type: Arrays related
Bug description: uasort overwrite bug
Description:
------------
uasort overwrites the last element in a large associative array with
incrementing numbers
Reproduce code:
---------------
$detaildata = array();
for($i = 0; $i < 6; $i++) {
$lid = rand(1,200);
$numpeople = rand(0,12);
for($p = 0; $p < $numpeople; $p++) {
$pid = rand(1,200);
$detaildata[$lid][$pid] = array("string data","string
data",$pid);
}
}
$detaildata[9][44] = array("string data","string data",44);
//
foreach($detaildata as &$row) {
uasort($row,CalSortCallback);
}
//
echo is_array($detaildata[9])?'yes':'no';
for($row = 0; $row < 5; $row++) {
echo is_array($detaildata[9])?'yes':$detaildata[9];
}
//
function CalSortCallback($a,$b) {
return strcmp($a[1],$b[1]);
}
Expected result:
----------------
it should print 6 yeses
yesyesyesyesyesyes
Actual result:
--------------
it prints yes01234
--
Edit bug report at http://bugs.php.net/?id=45708&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45708&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45708&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45708&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45708&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45708&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45708&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45708&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45708&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45708&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45708&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45708&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45708&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45708&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45708&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45708&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45708&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45708&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45708&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45708&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45708&r=mysqlcfg