-
Bug
-
Resolution: Fixed
-
Critical
-
3.5.5, 3.6.3
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-65218-master -
-
Steps to reproduce:
- Login as admin
- Go to /admin/settings.php?section=automated
- Enable and configure automated backup as usual
- Set backup | backup_auto_storage = specified directory for automated backups
- Set backup | backup_auto_destination to a directory where the webserver is allowed to write to, for example /var/www/foo
- Login as teacher
- Go to a course
- Create an arbitrary activity
- Delete this activity
- Go to the course's recycle bin
- Wait some time for the adhoc background task which should move the activity to recycle bin to finish
Expected result:
- The deleted activity is visible in the recycle bin
Actual result:
- The deleted activity is not visible in the recycle bin
- Instead, there is a new file called similar to backup-moodle2-activity-9022-20190329-1302.mbz in /var/www/foo.
Analysis:
This is a regression of MDL-63263. With the change in https://github.com/moodle/moodle/commit/5810888077b66a21f48bb5ce3f5eeef71016ec5b#diff-4c349047314dcebe0c39920f3a8ce822R122, not only the backup settings are taken from the automated backup configuration, but also the backup destination.
As backup | backup_auto_storage is set to the specified directory for automated backups, the backuped activity can't be moved from the automated backups file area to the recycle bin filearea anymore.
Possible solution:
As already pointed out by stronk7 in https://tracker.moodle.org/browse/MDL-63263?focusedCommentId=662570&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-662570, the re-use of backup mode MODE_AUTOMATED should most probably be replaced by a new MODE_RECYCLEBIN. I would not want to still re-use MODE_AUTOMATED and to have to recurve the backup destination in case we are backuping from recycling bin.
Hotfix:
You can circumvent the regression either by setting backup | backup_auto_storage = Course backup file area temporarily (which has its own implications as you most probably didn't want this when you decided for specified directory for automated backups) or you can roll back the important parts of MDL-63263 with
[root@moodle1 recyclebin]# git diff
|
diff --git a/admin/tool/recyclebin/classes/course_bin.php b/admin/tool/recyclebin/classes/course_bin.php
|
index d58d1a7..fb5d779 100644
|
--- a/admin/tool/recyclebin/classes/course_bin.php
|
+++ b/admin/tool/recyclebin/classes/course_bin.php
|
@@ -119,7 +119,7 @@ class course_bin extends base_bin {
|
$cm->id,
|
\backup::FORMAT_MOODLE,
|
\backup::INTERACTIVE_NO,
|
- \backup::MODE_AUTOMATED,
|
+ \backup::MODE_GENERAL,
|
$user->id
|
);
|
$controller->execute_plan();
|
@@ -224,7 +224,7 @@ class course_bin extends base_bin {
|
$tempdir,
|
$this->_courseid,
|
\backup::INTERACTIVE_NO,
|
- \backup::MODE_AUTOMATED,
|
+ \backup::MODE_GENERAL,
|
$user->id,
|
\backup::TARGET_EXISTING_ADDING
|
);
|
@@ -344,4 +344,4 @@ class course_bin extends base_bin {
|
$context = \context_course::instance($this->_courseid);
|
return has_capability('tool/recyclebin:deleteitems', $context);
|
}
|