From b14ab12b1dc5399de889322837fa752bf30c6dfe Mon Sep 17 00:00:00 2001 From: meirzamoodle Date: Thu, 3 Oct 2024 10:24:52 +0700 Subject: [PATCH] MDL-66873 backup: Remove all MODE_HUB related code --- .upgradenotes/MDL-66873-2024100408234440.yml | 5 +++++ backup/backup.class.php | 1 - backup/controller/backup_controller.class.php | 2 +- backup/moodle2/backup_course_task.class.php | 2 +- backup/moodle2/restore_course_task.class.php | 4 ++-- backup/util/checks/backup_check.class.php | 2 +- backup/util/checks/restore_check.class.php | 2 +- backup/util/helper/backup_helper.class.php | 10 ---------- 8 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 .upgradenotes/MDL-66873-2024100408234440.yml diff --git a/.upgradenotes/MDL-66873-2024100408234440.yml b/.upgradenotes/MDL-66873-2024100408234440.yml new file mode 100644 index 0000000000000..648e820f87786 --- /dev/null +++ b/.upgradenotes/MDL-66873-2024100408234440.yml @@ -0,0 +1,5 @@ +issueNumber: MDL-66873 +notes: + core_backup: + - message: Remove all MODE_HUB related code. + type: removed diff --git a/backup/backup.class.php b/backup/backup.class.php index ed1c877530435..a85112a4c6c8a 100644 --- a/backup/backup.class.php +++ b/backup/backup.class.php @@ -64,7 +64,6 @@ abstract class backup implements checksumable { * during a restore they are copied from the existing file record. */ const MODE_IMPORT = 20; - const MODE_HUB = 30; /** * This mode is intended for duplicating courses and cases where the backup target is diff --git a/backup/controller/backup_controller.class.php b/backup/controller/backup_controller.class.php index 8fb30a78257bd..ffa2c61b2099b 100644 --- a/backup/controller/backup_controller.class.php +++ b/backup/controller/backup_controller.class.php @@ -144,7 +144,7 @@ class backup_controller extends base_controller { * @param int $id The ID of the item to backup; e.g the course id * @param string $format The backup format to use; Most likely backup::FORMAT_MOODLE * @param bool $interactive Whether this backup will require user interaction; backup::INTERACTIVE_YES or INTERACTIVE_NO - * @param int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB, MODE_AUTOMATED + * @param int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_AUTOMATED * @param int $userid The id of the user making the backup * @param bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO */ diff --git a/backup/moodle2/backup_course_task.class.php b/backup/moodle2/backup_course_task.class.php index 83162080a61c8..4f27232382ea4 100644 --- a/backup/moodle2/backup_course_task.class.php +++ b/backup/moodle2/backup_course_task.class.php @@ -76,7 +76,7 @@ public function build() { $this->add_step(new backup_course_structure_step('course_info', 'course.xml')); // Generate the enrolment file (conditionally, prevent it in any IMPORT/HUB operation) - if ($this->plan->get_mode() != backup::MODE_IMPORT && $this->plan->get_mode() != backup::MODE_HUB) { + if ($this->plan->get_mode() != backup::MODE_IMPORT) { $this->add_step(new backup_enrolments_structure_step('course_enrolments', 'enrolments.xml')); } diff --git a/backup/moodle2/restore_course_task.class.php b/backup/moodle2/restore_course_task.class.php index 46629222f6a44..d52ffa0dec075 100644 --- a/backup/moodle2/restore_course_task.class.php +++ b/backup/moodle2/restore_course_task.class.php @@ -84,8 +84,8 @@ public function build() { if ($this->plan->get_mode() == backup::MODE_IMPORT) { // No need to do anything with enrolments. - } else if (!$this->get_setting_value('users') or $this->plan->get_mode() == backup::MODE_HUB) { - if ($this->get_setting_value('enrolments') == backup::ENROL_ALWAYS && $this->plan->get_mode() != backup::MODE_HUB) { + } else if (!$this->get_setting_value('users')) { + if ($this->get_setting_value('enrolments') == backup::ENROL_ALWAYS) { // Restore enrolment methods. $this->add_step(new restore_enrolments_structure_step('course_enrolments', 'enrolments.xml')); } else if ($this->get_target() == backup::TARGET_CURRENT_ADDING or $this->get_target() == backup::TARGET_EXISTING_ADDING) { diff --git a/backup/util/checks/backup_check.class.php b/backup/util/checks/backup_check.class.php index 7cd4c14af5455..6fca24218bff0 100644 --- a/backup/util/checks/backup_check.class.php +++ b/backup/util/checks/backup_check.class.php @@ -206,7 +206,7 @@ public static function check_security($backup_controller, $apply) { // Now, if mode is HUB or IMPORT, and still we are including users in backup, turn them off // Defaults processing should have handled this, but we need to be 100% sure - if ($mode == backup::MODE_IMPORT || $mode == backup::MODE_HUB) { + if ($mode == backup::MODE_IMPORT) { $userssetting = $backup_controller->get_plan()->get_setting('users'); if ($userssetting->get_value()) { $userssetting->set_value(false); // Set the value to false diff --git a/backup/util/checks/restore_check.class.php b/backup/util/checks/restore_check.class.php index 35fe2d9bf9b85..c1e376cd26a8a 100644 --- a/backup/util/checks/restore_check.class.php +++ b/backup/util/checks/restore_check.class.php @@ -138,7 +138,7 @@ public static function check_security($restore_controller, $apply) { // Now, if mode is HUB or IMPORT, and still we are including users in restore, turn them off // Defaults processing should have handled this, but we need to be 100% sure - if ($mode == backup::MODE_IMPORT || $mode == backup::MODE_HUB) { + if ($mode == backup::MODE_IMPORT) { $userssetting = $restore_controller->get_plan()->get_setting('users'); if ($userssetting->get_value()) { $userssetting->set_value(false); // Set the value to false diff --git a/backup/util/helper/backup_helper.class.php b/backup/util/helper/backup_helper.class.php index f377fb138b1a5..25957b1ec3443 100644 --- a/backup/util/helper/backup_helper.class.php +++ b/backup/util/helper/backup_helper.class.php @@ -317,16 +317,6 @@ public static function store_backup_file($backupid, $filepath, ?\core\progress\b } } - // Backups of type HUB (by definition never have user info) - // are sent to user's "user_tohub" file area. The upload process - // will be responsible for cleaning that filearea once finished - if ($backupmode == backup::MODE_HUB) { - $ctxid = context_user::instance($userid)->id; - $component = 'user'; - $filearea = 'tohub'; - $itemid = 0; - } - // Backups without user info or with the anonymise functionality // enabled are sent to user's "user_backup" // file area. Maintenance of such area is responsibility of