Merge branch 'wip-MDL-33338-master' of git://github.com/marinaglancy/moodle
[moodle.git] / lib / filestorage / file_storage.php
index 5fac726..9f0a3c2 100644 (file)
@@ -1260,6 +1260,8 @@ class file_storage {
             $filerecord->timemodified = $now;
         }
 
+        $transaction = $DB->start_delegated_transaction();
+
         // Insert file reference record.
         try {
             $referencerecord = new stdClass;
@@ -1292,6 +1294,8 @@ class file_storage {
 
         $this->create_directory($filerecord->contextid, $filerecord->component, $filerecord->filearea, $filerecord->itemid, $filerecord->filepath, $filerecord->userid);
 
+        $transaction->allow_commit();
+
         // Adding repositoryid and reference to file record to create stored_file instance
         $filerecord->repositoryid = $repositoryid;
         $filerecord->reference = $reference;