Merge branch 'w36_MDL-29257_m22_uniqid' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 12 Sep 2011 04:30:44 +0000 (16:30 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 12 Sep 2011 04:30:44 +0000 (16:30 +1200)
files/externallib.php
lib/outputcomponents.php
repository/lib.php

index eba388b..dc351b6 100644 (file)
@@ -210,7 +210,7 @@ class moodle_file_external extends external_api {
         $dir = make_upload_directory('temp/wsupload');
 
         if (empty($fileinfo['filename'])) {
-            $filename = uniqid('wsupload').'_'.time().'.tmp';
+            $filename = uniqid('wsupload', true).'_'.time().'.tmp';
         } else {
             $filename = $fileinfo['filename'];
         }
index 9a4a123..f822ef9 100644 (file)
@@ -999,7 +999,15 @@ class html_writer {
      * @return string
      */
     public static function random_id($base='random') {
-        return uniqid($base);
+        static $counter = 0;
+        static $uniq;
+
+        if (!isset($uniq)) {
+            $uniq = uniqid();
+        }
+
+        $counter++;
+        return $base.$uniq.$counter;
     }
 
     /**
index 965d9d8..b6f09a7 100644 (file)
@@ -1317,7 +1317,7 @@ abstract class repository {
             $dir = $CFG->dataroot.'/temp/download/';
         }
         if (empty($filename)) {
-            $filename = uniqid('repo').'_'.time().'.tmp';
+            $filename = uniqid('repo', true).'_'.time().'.tmp';
         }
         if (file_exists($dir.$filename)) {
             $filename = uniqid('m').$filename;