Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-27233 move the restorer enrol/ra creation to the very beginning o…
…f the restore process

Some early steps in restore are using capability checks to decide how to
restore some information. But at that stage, if the course contents have
been removed and the user had perms at course level only (usually teacher)
the process can fail because some content is not restoreable due to the
lack of permissions.

Moving the restorer step to the beginning really helps is those situations
and it does not hurt at all.

Also, fixed one notice detected when testing this.
  • Loading branch information
stronk7 committed Nov 25, 2011
1 parent 2afaf48 commit ede7105
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions backup/moodle2/restore_course_task.class.php
Expand Up @@ -74,9 +74,6 @@ public function build() {
$this->add_step(new restore_enrolments_structure_step('course_enrolments', 'enrolments.xml'));
}

// Now make sure the user that is running the restore can actually access the course
$this->add_step(new restore_fix_restorer_access_step('fix_restorer_access'));

// Restore course filters (conditionally)
if ($this->get_setting_value('filters')) {
$this->add_step(new restore_filters_structure_step('course_filters', 'filters.xml'));
Expand Down
4 changes: 4 additions & 0 deletions backup/moodle2/restore_root_task.class.php
Expand Up @@ -37,6 +37,10 @@ public function build() {
// Conditionally create the temp table (can exist from prechecks) and delete old stuff
$this->add_step(new restore_create_and_clean_temp_stuff('create_and_clean_temp_stuff'));

// Now make sure the user that is running the restore can actually access the course
// before executing any other step (potentially performing permission checks)
$this->add_step(new restore_fix_restorer_access_step('fix_restorer_access'));

// If we haven't preloaded information, load all the included inforef records to temp_ids table
$this->add_step(new restore_load_included_inforef_records('load_inforef_records'));

Expand Down
2 changes: 1 addition & 1 deletion backup/util/dbops/restore_dbops.class.php
Expand Up @@ -1201,7 +1201,7 @@ public static function process_categories_and_questions($restoreid, $courseid, $
// With problems of type error, throw exception, shouldn't happen if prechecks were originally
// executed, so be radical here.
if (array_key_exists('errors', $problems)) {
throw new restore_dbops_exception('restore_problems_processing_questions', null, implode(', ', $problems));
throw new restore_dbops_exception('restore_problems_processing_questions', null, implode(', ', $problems['errors']));
}
}

Expand Down

0 comments on commit ede7105

Please sign in to comment.