From 53c88025456d79527e9368aeed1167db944625be Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 16 Jun 2022 10:36:51 +0100 Subject: [PATCH] MDL-74988 core: reset times for entire filearea in upgrade test. The previous code was resetting timestamps for only the file itself, which could lead to it having an earlier time than the root entry of it's filearea. This caused sporadic test failures when the current time ticked over by a second during execution. --- lib/tests/upgradelib_test.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index 58ad609172c..190051631b6 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -1704,8 +1704,19 @@ calendar,core_calendar|/calendar/view.php?view=month', $oldfile = $fs->create_file_from_string($old, 'old'); // Manually set the timestamps to use on files. - $DB->set_field('files', 'timecreated', $origtime, ['id' => $newfile->get_id()]); - $DB->set_field('files', 'timemodified', $origtime, ['id' => $newfile->get_id()]); + $DB->set_field('files', 'timecreated', $origtime, [ + 'contextid' => $newfile->get_contextid(), + 'component' => $newfile->get_component(), + 'filearea' => $newfile->get_filearea(), + 'itemid' => $newfile->get_itemid(), + ]); + $DB->set_field('files', 'timemodified', $origtime, [ + 'contextid' => $newfile->get_contextid(), + 'component' => $newfile->get_component(), + 'filearea' => $newfile->get_filearea(), + 'itemid' => $newfile->get_itemid(), + ]); + $DB->set_field('files', 'timecreated', 1, ['id' => $oldfile->get_id()]); $DB->set_field('files', 'timemodified', 1, ['id' => $oldfile->get_id()]);