diff --git a/lib/classes/fileredact/services/exifremover_service.php b/lib/classes/fileredact/services/exifremover_service.php index 81c342cb33e..9bc5f56e66f 100644 --- a/lib/classes/fileredact/services/exifremover_service.php +++ b/lib/classes/fileredact/services/exifremover_service.php @@ -230,6 +230,8 @@ class exifremover_service extends service { 'itemid' => $this->storedfile->get_itemid(), 'filepath' => $this->storedfile->get_filepath(), 'filename' => $this->storedfile->get_filename(), + 'repositoryid' => $this->storedfile->get_repository_id(), + 'reference' => $this->storedfile->get_reference(), ]; $fs = get_file_storage(); $existingfile = $fs->get_file( diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 732490063b5..372cabcda09 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -1493,6 +1493,10 @@ class file_storage { $newrecord->pathnamehash = $this->get_pathname_hash($newrecord->contextid, $newrecord->component, $newrecord->filearea, $newrecord->itemid, $newrecord->filepath, $newrecord->filename); + if (!empty($filerecord->repositoryid)) { + $newrecord->referencefileid = $this->get_or_create_referencefileid($filerecord->repositoryid, $filerecord->reference); + } + try { $this->create_file($newrecord, $notify); } catch (dml_exception $e) {