From 469e7dd82de64054ddf35bc8712be0a8ab1e33fe Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sun, 8 Jun 2014 21:49:53 -0700 Subject: [PATCH] MDL-45721 core_backup: only trigger the course_restored event when restoring a course --- backup/util/plan/restore_plan.class.php | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/backup/util/plan/restore_plan.class.php b/backup/util/plan/restore_plan.class.php index 6f5b5b5bf91..acfb7b3153f 100644 --- a/backup/util/plan/restore_plan.class.php +++ b/backup/util/plan/restore_plan.class.php @@ -167,18 +167,21 @@ class restore_plan extends base_plan implements loggable { parent::execute(); $this->controller->set_status(backup::STATUS_FINISHED_OK); - // Trigger a course restored event. - $event = \core\event\course_restored::create(array( - 'objectid' => $this->get_courseid(), - 'userid' => $this->get_userid(), - 'context' => context_course::instance($this->get_courseid()), - 'other' => array('type' => $this->controller->get_type(), - 'target' => $this->controller->get_target(), - 'mode' => $this->controller->get_mode(), - 'operation' => $this->controller->get_operation(), - 'samesite' => $this->controller->is_samesite()) - )); - $event->trigger(); + // Check if we are restoring a course. + if ($this->controller->get_type() === backup::TYPE_1COURSE) { + // Trigger a course restored event. + $event = \core\event\course_restored::create(array( + 'objectid' => $this->get_courseid(), + 'userid' => $this->get_userid(), + 'context' => context_course::instance($this->get_courseid()), + 'other' => array('type' => $this->controller->get_type(), + 'target' => $this->controller->get_target(), + 'mode' => $this->controller->get_mode(), + 'operation' => $this->controller->get_operation(), + 'samesite' => $this->controller->is_samesite()) + )); + $event->trigger(); + } } /**