Skip to content

Commit

Permalink
Merge branch 'master-MDL-70337' of https://github.com/golenkovm/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jun 2, 2021
2 parents 73d178e + ed5e808 commit 9d9352e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions backup/tests/automated_backup_test.php
Expand Up @@ -119,8 +119,7 @@ public function test_automated_backup_skipped_run() {
$method->setAccessible(true); // Allow accessing of private method.
$emailpending = $method->invokeArgs($classobject, [$courses, $admin]);

$coursename = $this->course->fullname;
$this->expectOutputRegex("/Skipping $coursename \(Not scheduled for backup until/");
$this->expectOutputRegex('/Skipping course id ' . $this->course->id . ': Not scheduled for backup until/');
$this->assertFalse($emailpending);

$backupcourse = $DB->get_record('backup_courses', array('courseid' => $this->course->id));
Expand Down Expand Up @@ -162,8 +161,7 @@ public function test_automated_backup_push_run() {
$emailpending = $method->invokeArgs($classobject, [$courses, $admin]);
$this->assertTrue($emailpending);

$coursename = $this->course->fullname;
$this->expectOutputRegex("/Putting backup of $coursename in adhoc task queue/");
$this->expectOutputRegex('/Putting backup of course id ' . $this->course->id. ' in adhoc task queue/');

$backupcourse = $DB->get_record('backup_courses', array('courseid' => $this->course->id));
// Now this backup course status should be queued.
Expand Down Expand Up @@ -206,7 +204,7 @@ public function test_should_skip_invisible_course() {
$skipped = $method->invokeArgs($classobject, [$backupcourse, $course, $nextstarttime]);

$this->assertTrue($skipped);
$this->expectOutputRegex("/Skipping $course->fullname \(Not visible\)/");
$this->expectOutputRegex('/Skipping course id ' . $this->course->id. ': Not visible/');
}

/**
Expand Down Expand Up @@ -241,7 +239,7 @@ public function test_should_skip_not_modified_course_in_days() {
$skipped = $method->invokeArgs($classobject, [$backupcourse, $course, $nextstarttime]);

$this->assertTrue($skipped);
$this->expectOutputRegex("/Skipping $course->fullname \(Not modified in the past 2 days\)/");
$this->expectOutputRegex('/Skipping course id ' . $this->course->id . ': Not modified in the past 2 days/');
}

/**
Expand Down Expand Up @@ -276,7 +274,7 @@ public function test_should_skip_not_modified_course_since_prev() {
$skipped = $method->invokeArgs($classobject, [$backupcourse, $course, $nextstarttime]);

$this->assertTrue($skipped);
$this->expectOutputRegex("/Skipping $course->fullname \(Not modified since previous backup\)/");
$this->expectOutputRegex('/Skipping course id ' . $this->course->id . ': Not modified since previous backup/');
}

/**
Expand Down
10 changes: 4 additions & 6 deletions backup/util/helper/backup_cron_helper.class.php
Expand Up @@ -289,21 +289,20 @@ private static function check_and_push_automated_backups($courses, $admin) {
if (!$shouldrunnow || $backupcourse->laststatus == self::BACKUP_STATUS_QUEUED) {
$backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse);
mtrace('Skipping ' . $course->fullname . ' (Not scheduled for backup until ' . $showtime . ')');
mtrace('Skipping course id ' . $course->id . ': Not scheduled for backup until ' . $showtime);
} else {
$skipped = self::should_skip_course_backup($backupcourse, $course, $nextstarttime);
$skipped = self::should_skip_course_backup($backupcourse, $course, $nextstarttime);
if (!$skipped) { // If it should not be skipped.

// Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error or being backed up).
if ($backupcourse->laststatus != self::BACKUP_STATUS_UNFINISHED) {
// Add every non-skipped courses to backup adhoc task queue.
mtrace('Putting backup of ' . $course->fullname . ' in adhoc task queue ...');
mtrace('Putting backup of course id ' . $course->id . ' in adhoc task queue');

// We have to send an email because we have included at least one backup.
$emailpending = true;
// Create adhoc task for backup.
self::push_course_backup_adhoc_task($backupcourse, $admin);
mtrace("complete - next execution: $showtime");
}
}
}
Expand Down Expand Up @@ -363,8 +362,7 @@ private static function should_skip_course_backup($backupcourse, $course, $nexts
$backupcourse->laststatus = self::BACKUP_STATUS_SKIPPED;
$backupcourse->nextstarttime = $nextstarttime;
$DB->update_record('backup_courses', $backupcourse);
mtrace('Skipping ' . $course->fullname . ' (' . $skippedmessage . ')');
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . date('r', $nextstarttime));
mtrace('Skipping course id ' . $course->id . ': ' . $skippedmessage);
}

return $skipped;
Expand Down

0 comments on commit 9d9352e

Please sign in to comment.