Permalink
Browse files

MDL-41198 lib: Allow PHP to generate random seed on script start

Most srand instances are removed to allow PHP to do the work.

srand was left for group randomization due to the method used.
  • Loading branch information...
1 parent dd7e948 commit 9c5c2dbf5ad3037eb4f9542d0d56ba54fbd686d2 @mr-russ mr-russ committed Nov 22, 2013
Showing with 0 additions and 11 deletions.
  1. +0 −1 auth/mnet/auth.php
  2. +0 −5 lib/adodb/adodb.inc.php
  3. +0 −1 lib/cronlib.php
  4. +0 −2 lib/moodlelib.php
  5. +0 −2 lib/tests/accesslib_test.php
View
@@ -941,7 +941,6 @@ function cron() {
// run the keepalive client
$this->keepalive_client();
- // admin/cron.php should have run srand for us
$random100 = rand(0,100);
if ($random100 < 10) { // Approximately 10% of the time.
// nuke olden sessions
View
@@ -169,11 +169,6 @@ function ADODB_Setup()
die("Illegal path http:// or ftp://");
}
-
- // Initialize random number generator for randomizing cache flushes
- // -- note Since PHP 4.2.0, the seed becomes optional and defaults to a random value if omitted.
- srand(((double)microtime())*1000000);
-
/**
* ADODB version as a string.
*/
View
@@ -66,7 +66,6 @@ function cron_run() {
// Run cleanup core cron jobs, but not every time since they aren't too important.
// These don't have a timer to reduce load, so we'll use a random number
// to randomly choose the percentage of times we should run these jobs.
- srand ((double) microtime() * 10000000);
$random100 = rand(0,100);
if ($random100 < 20) { // Approximately 20% of the time.
mtrace("Running clean-up tasks...");
View
@@ -7969,7 +7969,6 @@ function unformat_float($localefloat, $strict = false) {
*/
function swapshuffle($array) {
- srand ((double) microtime() * 10000000);
$last = count($array) - 1;
for ($i = 0; $i <= $last; $i++) {
$from = rand(0, $last);
@@ -8009,7 +8008,6 @@ function swapshuffle_assoc($array) {
* @return array
*/
function draw_rand_array($array, $draws) {
- srand ((double) microtime() * 10000000);
$return = array();
@@ -2274,8 +2274,6 @@ public function test_permission_evaluation() {
$userids = array_slice($userids, 0, 5);
}
- // Random time!
- // srand(666);
foreach ($userids as $userid) { // No guest or deleted.
// Each user gets 0-10 random roles.
$rcount = rand(0, 10);

0 comments on commit 9c5c2db

Please sign in to comment.