]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed wroing using of static cache
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 17:51:54 +0000 (17:51 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 17:51:54 +0000 (17:51 +0000)
mod/workshop/lib.php

index 4793818a2501e36006ce137c877a89fe0f94974a..6643c676a161fd09fe0855c531d42295baafb813 100644 (file)
@@ -377,7 +377,6 @@ function workshop_pluginfile($course, $cminfo, $context, $filearea, $args, $forc
  */
 function workshop_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
     global $CFG, $DB;
-    static $authors=null;    // cache for submission authors
 
     if (!has_capability('moodle/course:managefiles', $context)) {
         return null;
@@ -407,15 +406,14 @@ function workshop_get_file_info($browser, $areas, $course, $cm, $context, $filea
         }
 
         // let us display the author's name instead of itemid (submission id)
-
-        if (is_null($authors)) {
-            $sql = 'SELECT s.id, u.lastname, u.firstname
-                    FROM {workshop_submissions} s
-                    JOIN {user} u ON (s.userid = u.id)
-                    WHERE s.workshopid = ?';
-            $params[0] = $cm->instance;
-            $authors = $DB->get_records_sql($sql, $params);
-        }
+        // todo some sort of caching should happen here
+
+        $sql = "SELECT s.id, u.lastname, u.firstname
+                  FROM {workshop_submissions} s
+            INNER JOIN {user} u ON (s.userid = u.id)
+                 WHERE s.workshopid = ?";
+        $params         = array($cm->instance);
+        $authors        = $DB->get_records_sql($sql, $params);
         $urlbase        = $CFG->wwwroot . '/pluginfile.php';
         $topvisiblename = fullname($authors[$itemid]);
         // do not allow manual modification of any files!