Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-MDL-25454-MOODLE_20_STABLE' of git://github.com/mar…

…inaglancy/moodle into MOODLE_20_STABLE
  • Loading branch information...
commit 8bd76f9e652e621411ba2d0b9403b9423cc87462 2 parents c06645a + 44e9ca7
@samhemelryk samhemelryk authored
Showing with 17 additions and 7 deletions.
  1. +17 −7 backup/util/helper/backup_cron_helper.class.php
View
24 backup/util/helper/backup_cron_helper.class.php
@@ -123,14 +123,24 @@ public static function run_automated_backup($rundirective = self::RUN_ON_SCHEDUL
$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
+ $sqlwhere = "course=:courseid AND time>:time AND ". $DB->sql_like('action', ':action', false, true, true);
+ $params = array('courseid' => $course->id, 'time' => $now-31*24*60*60, 'action' => '%view%');
+ $logexists = $DB->record_exists_select('log', $sqlwhere, $params);
+ if (!$logexists) {
+ $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
Please sign in to comment.
Something went wrong with that request. Please try again.