Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-25454

Scheduled backups skip hidden courses, even if they have been modified

XMLWordPrintable

    • Any
    • MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE
    • wip-MDL-25454-master
    • Hide

      Important: This must be tested in 19_STABLE and 21_STABLE (20 and master are 100% equivalent to 21)

      1. Hide a course
      2. In the database, change mdl_course.timemodified to a Unix timestamp older than 31 days, e.g. UPDATE mdl_course SET timemodified = UNIX_TIMESTAMP() - 32 * 86400
      3. Make some changes to the course, e.g. add some resources. It would be better to make changes in the resources or activities
      4. Trigger a scheduled backup

      Show
      Important: This must be tested in 19_STABLE and 21_STABLE (20 and master are 100% equivalent to 21) 1. Hide a course 2. In the database, change mdl_course.timemodified to a Unix timestamp older than 31 days, e.g. UPDATE mdl_course SET timemodified = UNIX_TIMESTAMP() - 32 * 86400 3. Make some changes to the course, e.g. add some resources. It would be better to make changes in the resources or activities 4. Trigger a scheduled backup

      backup/backup_scheduled.php contains code that prevents hidden courses from being backed up if they have not been modified in the last month:

      // 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");
          $DB->set_field("backup_courses","laststatus","3", array("courseid"=>$backup_course->courseid));
          $skipped = true;
      }

      However, $course->timemodified is only changed when the function "update_course" is called. This only happens when the course's "settings" page (course/edit.php) has been submitted with changes.

      If a user is editing a course while it is hidden from students, it will not be backed up unless they change a setting.

      Steps to reproduce:

      1. Hide a course
      2. In the database, change mdl_course.timemodified to a Unix timestamp older than 31 days, e.g. UPDATE mdl_course SET timemodified = UNIX_TIMESTAMP() - 32 * 86400
      3. Make some changes to the course, e.g. add some resources.
      4. Trigger a scheduled backup

      Expected outcome: The course is backed up

      Observed outcome: The course is skipped during scheduled backup, and no backup file is created.

      I'm not sure what the best fix is. Something that queries mdl_log, perhaps, e.g.

      SELECT MAX(time) from mdl_log WHERE course = <course id> AND action IN (<list of "update"-type actions>)

      Alternatively, perhaps there should be a mechanism for updating timemodified in mdl_course when such changes are made.

            marina Marina Glancy
            chrisf Chris Fryer
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Sam Hemelryk Sam Hemelryk
            Rajesh Taneja Rajesh Taneja
            Votes:
            27 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.