Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9, 1.9.1, 1.9.2
-
Fix Version/s: None
-
Component/s: Backup
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
I've just had the fun of merging some code in backup/backuplib.php from a development installation into our moodle head. A large part fo the code would benefit from what seems a very simple refactor. I'd do it but deadlines are looming.
I've logged this as major because I think it would tidy up a large part of this key method and make it easier to read and debug.
The code is in the method backup_execute. This method is generally following just a couple of patterns over and over again. Most of it looks like this
if (!defined('BACKUP_SILENTLY')) {
echo "<li>".get_string("blocks").'</li>';
}
//Blocks information
if ($status) {
if (!$status = backup_course_blocks($backup_file,$preferences)) {
$errorstr = "An error occurred while backing up course blocks";
backup_add_to_log(time(),$preferences->backup_course,$errorstr,'manual');
if (!defined('BACKUP_SILENTLY')) {
notify($errorstr);
} else {
return false;
}
}
}
repeated over and over again. This could easily be abstracted to a method or two and save maybe 500 - 1000 lines of code
This is a known problem, I hope the backup/restore will be rewritten in 2.0