MDL-39177 Updating userid when file is overwritten
authorMarina Glancy <marina@moodle.com>
Mon, 20 May 2013 04:09:11 +0000 (14:09 +1000)
committerMarina Glancy <marina@moodle.com>
Mon, 20 May 2013 04:09:11 +0000 (14:09 +1000)
lib/filelib.php
lib/filestorage/stored_file.php

index 51e3c23..30f7edf 100644 (file)
@@ -900,7 +900,8 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
             if (!$oldfile->is_directory() &&
                     ($oldfile->get_contenthash() != $newfile->get_contenthash() ||
                     $oldfile->get_filesize() != $newfile->get_filesize() ||
-                    $oldfile->get_referencefileid() != $newfile->get_referencefileid())) {
+                    $oldfile->get_referencefileid() != $newfile->get_referencefileid() ||
+                    $oldfile->get_userid() != $newfile->get_userid())) {
                 $oldfile->replace_file_with($newfile);
                 // push changes to all local files that are referencing this file
                 $fs->update_references_to_storedfile($oldfile);
index 2cc3e7e..fbce9af 100644 (file)
@@ -212,7 +212,7 @@ class stored_file {
 
     /**
      * Replaces the fields that might have changed when file was overriden in filepicker:
-     * reference, contenthash, filesize
+     * reference, contenthash, filesize, userid
      *
      * Note that field 'source' must be updated separately because
      * it has different format for draft and non-draft areas and
@@ -240,6 +240,7 @@ class stored_file {
         }
         $filerecord->filesize = $newfile->get_filesize();
         $filerecord->referencefileid = $newfile->get_referencefileid();
+        $filerecord->userid = $newfile->get_userid();
         $this->update($filerecord);
     }