MDL-39177 File reference is not updated when overwriting the file

This commit is contained in:
Marina Glancy
2013-05-14 17:07:53 +10:00
parent 93cbd15ec8
commit 73c6550ddb
4 changed files with 45 additions and 2 deletions
+7 -2
View File
@@ -828,9 +828,14 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
$oldfile->set_timemodified($newfile->get_timemodified());
}
if ($newfile->is_external_file() && !$allowreferences) {
continue;
}
// Replaced file content
if ($oldfile->get_contenthash() != $newfile->get_contenthash() || $oldfile->get_filesize() != $newfile->get_filesize()) {
$oldfile->replace_content_with($newfile);
else if ($oldfile->get_contenthash() != $newfile->get_contenthash() ||
$oldfile->get_filesize() != $newfile->get_filesize() ||
$oldfile->get_referencefileid() != $newfile->get_referencefileid()) {
$oldfile->replace_file_with($newfile);
// push changes to all local files that are referencing this file
$fs->update_references_to_storedfile($oldfile);
}