Skip to content

Commit

Permalink
MDL-65218 recycle bin: immunize recycle bin from backup_auto_storage
Browse files Browse the repository at this point in the history
As far as recycle bin is using MODE_AUTOMATED, it observes the backup_auto_storage
setting (storing backups @ real location. For recycle bin we want to ensure that
backup files are always stored in Moodle file area. In order to achieve that, we
hack the setting here via $CFG->forced_plugin_settings, so it won't interfere other
operations.  See MDL-65218 for more information.

This hack will be removed once recycle bin switches to use its own backup mode, with
own preferences and 100% appart from MODLE_AUTOMATED.
  • Loading branch information
stronk7 committed Mar 31, 2019
1 parent 8793f25 commit 311123b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions admin/tool/recyclebin/classes/category_bin.php
Expand Up @@ -108,6 +108,16 @@ public function store_item($course) {

require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');

// As far as recycle bin is using MODE_AUTOMATED, it observes the backup_auto_storage
// setting (storing backups @ real location. For recycle bin we want to ensure that
// backup files are always stored in Moodle file area. In order to achieve that, we
// hack the setting here via $CFG->forced_plugin_settings, so it won't interfere other
// operations. See MDL-65218 for more information.
// This hack will be removed once recycle bin switches to use its own backup mode, with
// own preferences and 100% appart from MODLE_AUTOMATED.
// TODO: Remove this as part of MDL-65228.
$CFG->forced_plugin_settings['backup'] = ['backup_auto_storage' => 0];

// Backup the course.
$user = get_admin();
$controller = new \backup_controller(
Expand All @@ -120,6 +130,10 @@ public function store_item($course) {
);
$controller->execute_plan();

// We don't need the forced setting anymore, hence unsetting it.
// TODO: Remove this as part of MDL-65228.
unset($CFG->forced_plugin_settings['backup']);

// Grab the result.
$result = $controller->get_results();
if (!isset($result['backup_destination'])) {
Expand Down
16 changes: 15 additions & 1 deletion admin/tool/recyclebin/classes/course_bin.php
Expand Up @@ -112,6 +112,16 @@ public function store_item($cm) {
return;
}

// As far as recycle bin is using MODE_AUTOMATED, it observes the backup_auto_storage
// setting (storing backups @ real location. For recycle bin we want to ensure that
// backup files are always stored in Moodle file area. In order to achieve that, we
// hack the setting here via $CFG->forced_plugin_settings, so it won't interfere other
// operations. See MDL-65218 for more information.
// This hack will be removed once recycle bin switches to use its own backup mode, with
// own preferences and 100% appart from MODLE_AUTOMATED.
// TODO: Remove this as part of MDL-65228.
$CFG->forced_plugin_settings['backup'] = ['backup_auto_storage' => 0];

// Backup the activity.
$user = get_admin();
$controller = new \backup_controller(
Expand All @@ -124,6 +134,10 @@ public function store_item($cm) {
);
$controller->execute_plan();

// We don't need the forced setting anymore, hence unsetting it.
// TODO: Remove this as part of MDL-65228.
unset($CFG->forced_plugin_settings['backup']);

// Grab the result.
$result = $controller->get_results();
if (!isset($result['backup_destination'])) {
Expand Down Expand Up @@ -344,4 +358,4 @@ public function can_delete() {
$context = \context_course::instance($this->_courseid);
return has_capability('tool/recyclebin:deleteitems', $context);
}
}
}

0 comments on commit 311123b

Please sign in to comment.