]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15977 create_file_from_storedfile should accept an original file object
authorskodak <skodak>
Sat, 16 Aug 2008 21:21:23 +0000 (21:21 +0000)
committerskodak <skodak>
Sat, 16 Aug 2008 21:21:23 +0000 (21:21 +0000)
lib/file/file_storage.php

index 353bf39f567490ebd758b5ac5152dc3dfe830fb4..5bb9e9f73fd3ed5267fe20a80d544da573daf6cf 100644 (file)
@@ -353,10 +353,15 @@ class file_storage {
     public function create_file_from_storedfile($file_record, $fid) {
         global $DB;
 
+        if ($fid instanceof stored_file) {
+            $fid = $fid->get_id();
+        }
+
         $file_record = (array)$file_record; // we support arrays too
         unset($file_record['id']);
         unset($file_record['filesize']);
         unset($file_record['contenthash']);
+        unset($file_record['pathnamehash']);
 
         $now = time();