From 245491b062961c2c395f472d820dd10ba45c4487 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Sat, 24 Jul 2010 16:31:16 +0000 Subject: [PATCH] MDL-21432 backup - improve a bit detection of errors on restore structured steps --- backup/util/plan/restore_structure_step.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backup/util/plan/restore_structure_step.class.php b/backup/util/plan/restore_structure_step.class.php index 8545f07c4b0..8a1db6c3f9f 100644 --- a/backup/util/plan/restore_structure_step.class.php +++ b/backup/util/plan/restore_structure_step.class.php @@ -75,7 +75,11 @@ abstract class restore_structure_step extends restore_step { } // Get restore_path elements array adapting and preparing it for processing - $this->pathelements = $this->prepare_pathelements($this->define_structure()); + $structure = $this->define_structure(); + if (!is_array($structure)) { + throw new restore_step_exception('restore_step_structure_not_array', $this->get_name()); + } + $this->pathelements = $this->prepare_pathelements($structure); // Populate $elementsoldid and $elementsoldid based on available pathelements foreach ($this->pathelements as $pathelement) { @@ -150,6 +154,9 @@ abstract class restore_structure_step extends restore_step { $names = array(); $paths = array(); foreach($elementsarr as $element) { + if (!$element instanceof restore_path_element) { + throw new restore_step_exception('restore_path_element_wrong_class', get_class($element)); + } if (array_key_exists($element->get_name(), $names)) { throw new restore_step_exception('restore_path_element_name_alreadyexists', $element->get_name()); } -- 2.43.0