From 2a918d8f551b45dfcb06081f2dbbf8a138cffbc1 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Tue, 31 Aug 2010 09:15:38 +0000 Subject: [PATCH] MDL-23362 backup - allow set_mapping() to specify one parentitemid to be saved --- backup/util/plan/restore_structure_step.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backup/util/plan/restore_structure_step.class.php b/backup/util/plan/restore_structure_step.class.php index 22688f64c64..c1b51ad45d5 100644 --- a/backup/util/plan/restore_structure_step.class.php +++ b/backup/util/plan/restore_structure_step.class.php @@ -133,13 +133,19 @@ abstract class restore_structure_step extends restore_step { * by children. Also will inject the known old context id for the task * in case it's going to be used for restoring files later */ - public function set_mapping($itemname, $oldid, $newid, $restorefiles = false, $filesctxid = null) { + public function set_mapping($itemname, $oldid, $newid, $restorefiles = false, $filesctxid = null, $parentid = null) { + if ($restorefiles && $parentid) { + throw new restore_step_exception('set_mapping_cannot_specify_both_restorefiles_and_parentitemid'); + } // If we haven't specified one context for the files, use the task one - if ($filesctxid == null) { + if (is_null($filesctxid)) { $parentitemid = $restorefiles ? $this->task->get_old_contextid() : null; } else { // Use the specified one $parentitemid = $restorefiles ? $filesctxid : null; } + // We have passed one explicit parentid, apply it + $parentitemid = !is_null($parentid) ? $parentid : $parentitemid; + // Let's call the low level one restore_dbops::set_backup_ids_record($this->get_restoreid(), $itemname, $oldid, $newid, $parentitemid); // Now, if the itemname matches any pathelement->name, store the latest $newid -- 2.43.0