Issue Details (XML | Word | Printable)

Key: MDL-15752
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Colin Chambers
Votes: 0
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

backup_execute() code coudl be refactored for easy maintenance

Created: 22/Jul/08 06:06 PM   Updated: 22/Jul/08 09:49 PM
Component/s: Backup
Affects Version/s: 1.9, 1.9.1, 1.9.2
Fix Version/s: None

Participants: Colin Chambers, Eloy Lafuente (stronk7) and Petr Škoda (skodak)
Security Level: None
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
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



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Škoda (skodak) added a comment - 22/Jul/08 09:46 PM
This is a known problem, I hope the backup/restore will be rewritten in 2.0

Colin Chambers added a comment - 22/Jul/08 09:49 PM
thanks petr. Sorry for maybe duplicating a bug but it would save a bit of hassle for anyone maintaining the code or merging it like me and dan. I thought ebtter to have two bugs than none at all.