From:
Operating system: window xp sp3
PHP version: 5.3.12
Package: Arrays related
Bug Type: Bug
Bug description:array_rand seed no refresh bug
Description:
------------
run test_array_rand.php
Test script:
---------------
<?php
$array = array_fill(0, 1000, 'a');
echo rand(0 , 10000);
function ref(&$data = false)
{
global $array;
$data = &$array;
$a = randArray($data);
}
function randArray($data)
{
global $array;
//may be wrong here
$array[] = array_rand($array, 1);
return $data[rand(0, sizeof($data) - 1)];
}
$i = 1000;
while ($i--)
ref()
// Hi refresh it 3 - 10 times
// you will see
// random number no longer random
// 1 return 10
// 2 return 4453
// 3 return 1251
// 4 return 10
// 5 return 4453
// 6 return 1251
// ...
?>
Expected result:
----------------
make rand(0, 10000) random
Actual result:
--------------
rand(0, 10000) no longer random
--
Edit bug report at https://bugs.php.net/bug.php?id=61963&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61963&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61963&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61963&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61963&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61963&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61963&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61963&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61963&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61963&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61963&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61963&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61963&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61963&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61963&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61963&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61963&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61963&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61963&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61963&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61963&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61963&r=mysqlcfg