From dd7e948dba9cf86bd1433332927aef4e7cc55acf Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Fri, 1 Nov 2013 09:36:05 +1100 Subject: [PATCH] MDL-41198 lib: Allow PHP to generate random seed on script start All mt_srand instances are removed to allow PHP to do the work. --- backup/cc/entities.class.php | 1 - lib/moodlelib.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/backup/cc/entities.class.php b/backup/cc/entities.class.php index c9e55264508..4f441ba4a3a 100644 --- a/backup/cc/entities.class.php +++ b/backup/cc/entities.class.php @@ -309,7 +309,6 @@ class entities { $source = str_split($source, 1); for ($i = 1; $i <= $length; $i++) { - mt_srand((double) microtime() * 1000000); $num = mt_rand(1, count($source)); $response .= $source[$num - 1]; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 6f53dcf1f44..4179c7d8885 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -7650,7 +7650,6 @@ function random_string ($length=15) { $pool .= 'abcdefghijklmnopqrstuvwxyz'; $pool .= '0123456789'; $poollen = strlen($pool); - mt_srand ((double) microtime() * 1000000); $string = ''; for ($i = 0; $i < $length; $i++) { $string .= substr($pool, (mt_rand()%($poollen)), 1); @@ -7671,7 +7670,6 @@ function complex_random_string($length=null) { $pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; $pool .= '`~!@#%^&*()_+-=[];,./<>?:{} '; $poollen = strlen($pool); - mt_srand ((double) microtime() * 1000000); if ($length===null) { $length = floor(rand(24, 32)); }