Skip to content

Commit

Permalink
MDL-55356 backup: Check setting exists before checking value
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Oct 12, 2017
1 parent e61ad18 commit afc8d59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions backup/moodle2/restore_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ public function build() {
$this->add_step(new restore_activity_competencies_structure_step('activity_competencies', 'competencies.xml'));

// Search reindexing, if enabled and if not restoring entire course.
if (\core_search\manager::is_indexing_enabled() &&
!($this->get_target() == backup::TARGET_NEW_COURSE ||
$this->get_setting_value('overwrite_conf'))) {
$this->add_step(new restore_activity_search_index('activity_search_index'));
if (\core_search\manager::is_indexing_enabled()) {
$wholecourse = $this->get_target() == backup::TARGET_NEW_COURSE;
$wholecourse = $wholecourse || ($this->setting_exists('overwrite_conf') && $this->get_setting_value('overwrite_conf'));
if (!$wholecourse) {
$this->add_step(new restore_activity_search_index('activity_search_index'));
}
}

// At the end, mark it as built
Expand Down
10 changes: 6 additions & 4 deletions backup/moodle2/restore_block_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ public function build() {
}

// Search reindexing (if enabled).
if (\core_search\manager::is_indexing_enabled() &&
!($this->get_target() == backup::TARGET_NEW_COURSE ||
$this->get_setting_value('overwrite_conf'))) {
$this->add_step(new restore_block_search_index('block_search_index'));
if (\core_search\manager::is_indexing_enabled()) {
$wholecourse = $this->get_target() == backup::TARGET_NEW_COURSE;
$wholecourse = $wholecourse || $this->setting_exists('overwrite_conf') && $this->get_setting_value('overwrite_conf');
if (!$required) {
$this->add_step(new restore_block_search_index('block_search_index'));
}
}

// At the end, mark it as built
Expand Down
10 changes: 6 additions & 4 deletions backup/moodle2/restore_final_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ public function build() {
$this->add_step(new restore_drop_and_clean_temp_stuff('drop_and_clean_temp_stuff'));

// If restoring to a new course or overwriting config, reindex the whole course.
if (\core_search\manager::is_indexing_enabled() &&
($this->get_target() == backup::TARGET_NEW_COURSE ||
$this->get_setting_value('overwrite_conf'))) {
$this->add_step(new restore_course_search_index('course_search_index'));
if (\core_search\manager::is_indexing_enabled()) {
$wholecourse = $this->get_target() == backup::TARGET_NEW_COURSE;
$wholecourse = $wholecourse || $this->setting_exists('overwrite_conf') && $this->get_setting_value('overwrite_conf');
if ($wholecourse) {
$this->add_step(new restore_course_search_index('course_search_index'));
}
}

$this->built = true;
Expand Down

0 comments on commit afc8d59

Please sign in to comment.