MDL-33093 invalidate the thumbnail in the local browser's cache on update
authorDavid Mudrak <david@moodle.com>
Fri, 18 May 2012 20:17:41 +0000 (22:17 +0200)
committerMarina Glancy <marina@moodle.com>
Mon, 21 May 2012 03:57:56 +0000 (11:57 +0800)
This adds &oid= parameter to the URL of file preview images. The
parameter is supposed to be ignored by draftfile.php and pluginfile.php.
It just holds some unique identification of the original file's
revision. Currently, we use the timestamp of the most recent
modification of the original file.

lib/filelib.php
repository/coursefiles/lib.php
repository/local/lib.php
repository/recent/lib.php
repository/user/lib.php

index 8d8faf4..09d26b0 100644 (file)
@@ -625,8 +625,8 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
                 $item->url = $itemurl->out();
                 $item->thumbnail = $OUTPUT->pix_url(file_extension_icon($item->filename, 32))->out(false);
                 if ($imageinfo = $file->get_imageinfo()) {
-                    $item->realthumbnail = $itemurl->out(false, array('preview' => 'thumb'));
-                    $item->realicon = $itemurl->out(false, array('preview' => 'tinyicon'));
+                    $item->realthumbnail = $itemurl->out(false, array('preview' => 'thumb', 'oid' => $file->get_timemodified()));
+                    $item->realicon = $itemurl->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
                     $item->image_width = $imageinfo['width'];
                     $item->image_height = $imageinfo['height'];
                 }
index 64fb1a0..1045731 100644 (file)
@@ -126,8 +126,8 @@ class repository_coursefiles extends repository {
                     );
                     if ($imageinfo = $child->get_imageinfo()) {
                         $fileurl = new moodle_url($child->get_url());
-                        $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb'));
-                        $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon'));
+                        $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $child->get_timemodified()));
+                        $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $child->get_timemodified()));
                         $node['image_width'] = $imageinfo['width'];
                         $node['image_height'] = $imageinfo['height'];
                     }
index 93bc5e8..9c204a9 100644 (file)
@@ -224,8 +224,8 @@ class repository_local_file {
             if ($imageinfo = $this->fileinfo->get_imageinfo()) {
                 // what a beautiful picture, isn't it
                 $fileurl = new moodle_url($this->fileinfo->get_url());
-                $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb'));
-                $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon'));
+                $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $this->fileinfo->get_timemodified()));
+                $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $this->fileinfo->get_timemodified()));
                 $node['image_width'] = $imageinfo['width'];
                 $node['image_height'] = $imageinfo['height'];
             }
index 25abf00..f7d91d4 100644 (file)
@@ -139,8 +139,8 @@ class repository_recent extends repository {
                     );
                     if ($imageinfo = $fileinfo->get_imageinfo()) {
                         $fileurl = new moodle_url($fileinfo->get_url());
-                        $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb'));
-                        $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon'));
+                        $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $fileinfo->get_timemodified()));
+                        $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified()));
                         $node['image_width'] = $imageinfo['width'];
                         $node['image_height'] = $imageinfo['height'];
                     }
index 9d0537a..d15f572 100644 (file)
@@ -117,8 +117,8 @@ class repository_user extends repository {
                         );
                         if ($imageinfo = $child->get_imageinfo()) {
                             $fileurl = new moodle_url($child->get_url());
-                            $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb'));
-                            $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon'));
+                            $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $child->get_timemodified()));
+                            $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $child->get_timemodified()));
                             $node['image_width'] = $imageinfo['width'];
                             $node['image_height'] = $imageinfo['height'];
                         }