Permalink
Browse files

MDL-25454 before skipping course backup make sure that there are no c…

…hange entries in it's log during the last month
  • Loading branch information...
1 parent 050504c commit b7df65036f544aef3c70f03167dec34bc5952a7a @marinaglancy marinaglancy committed Jul 25, 2011
Showing with 14 additions and 7 deletions.
  1. +14 −7 backup/backup_scheduled.php
@@ -100,15 +100,22 @@ function schedule_backup_cron() {
$status = false;
continue;
}
+ // Skip courses that do not yet need backup
+ $skipped = !($backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now);
// Skip backup of unavailable courses that have remained unmodified in a month
- $skipped = false;
- if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
- mtrace(" SKIPPING - hidden+unmodified");
- set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
- $skipped = true;
+ if (!$skipped && !$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 '.$CFG->prefix .'log l WHERE '.
+ 'l.course='. $course->id. ' AND l.time>'. ($now-31*24*60*60). " AND lower(l.action) not like '%view%'";
+ $logs = get_records_sql($sql, 0, 1);
+ if (empty($logs)) {
+ mtrace(" SKIPPING - hidden+unmodified");
+ set_field("backup_courses", "laststatus", "3", "courseid", $backup_course->courseid);
+ $skipped = true;
+ }
}
- //Now we backup every non skipped course with nextstarttime < now
- if (!$skipped && $backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now) {
+ //Now we backup every non-skipped course
+ if (!$skipped) {
//We have to send a email because we have included at least one backup
$emailpending = true;
//Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error)

0 comments on commit b7df650

Please sign in to comment.