mirror of
https://github.com/moodle/moodle.git
synced 2025-02-08 09:02:07 +01:00
MDL-25454 before skipping course backup make sure that there are no change entries in it's log during the last month. Store the nextstarttime even for courses that were not backed up
This commit is contained in:
parent
228d24fd97
commit
e2558cd3ab
@ -123,14 +123,25 @@ abstract class backup_cron_automated_helper {
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
}
|
||||
|
||||
// Skip courses that do not yet need backup
|
||||
$skipped = !(($backupcourse->nextstarttime >= 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY);
|
||||
// Skip backup of unavailable courses that have remained unmodified in a month
|
||||
$skipped = false;
|
||||
if (empty($course->visible) && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping unchanged course '.$course->fullname);
|
||||
$skipped = true;
|
||||
} else if (($backupcourse->nextstarttime >= 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY) {
|
||||
if (!$skipped && empty($course->visible) && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + settings were unmodified last month
|
||||
//Check log if there were any modifications to the course content
|
||||
$sql = "SELECT l.id FROM {log} l WHERE ".
|
||||
"l.course=:courseid AND l.time>:time AND ". $DB->sql_like('l.action', ':action', false, true, true);
|
||||
$params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%');
|
||||
$logs = $DB->get_records_sql($sql, $params, 0, 1);
|
||||
if (empty($logs)) {
|
||||
$backupcourse->laststatus = backup_cron_automated_helper::BACKUP_STATUS_SKIPPED;
|
||||
$backupcourse->nextstarttime = $nextstarttime;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping unchanged course '.$course->fullname);
|
||||
$skipped = true;
|
||||
}
|
||||
}
|
||||
//Now we backup every non-skipped course
|
||||
if (!$skipped) {
|
||||
mtrace('Backing up '.$course->fullname, '...');
|
||||
|
||||
//We have to send a email because we have included at least one backup
|
||||
|
Loading…
x
Reference in New Issue
Block a user