Skip to content

Commit

Permalink
MDL-66873 backup: Remove all MODE_HUB related code
Browse files Browse the repository at this point in the history
  • Loading branch information
meirzamoodle committed Oct 21, 2024
1 parent ecfcf00 commit b14ab12
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .upgradenotes/MDL-66873-2024100408234440.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
issueNumber: MDL-66873
notes:
core_backup:
- message: Remove all MODE_HUB related code.
type: removed
1 change: 0 additions & 1 deletion backup/backup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backup/controller/backup_controller.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_course_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/restore_course_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion backup/util/checks/backup_check.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backup/util/checks/restore_check.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions backup/util/helper/backup_helper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b14ab12

Please sign in to comment.