Skip to content

Commit

Permalink
MDL-25432 backup: Catching exception for orphan course modules and it…
Browse files Browse the repository at this point in the history
…'s block (if any), and logging them, no exception will be thrown for this now.
  • Loading branch information
Rajesh Taneja committed Feb 20, 2012
1 parent e0d5a17 commit 543301a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 17 additions & 6 deletions backup/moodle2/backup_plan_builder.class.php
Expand Up @@ -121,12 +121,23 @@ static protected function build_activity_plan($controller, $id) {

// Add the activity task, responsible for outputting
// all the module related information
$plan->add_task(backup_factory::get_backup_activity_task($controller->get_format(), $id));

// For the given activity, add as many block tasks as necessary
$blockids = backup_plan_dbops::get_blockids_from_moduleid($id);
foreach ($blockids as $blockid) {
$plan->add_task(backup_factory::get_backup_block_task($controller->get_format(), $blockid, $id));
try {
$plan->add_task(backup_factory::get_backup_activity_task($controller->get_format(), $id));

// For the given activity, add as many block tasks as necessary
$blockids = backup_plan_dbops::get_blockids_from_moduleid($id);
foreach ($blockids as $blockid) {
try {
$plan->add_task(backup_factory::get_backup_block_task($controller->get_format(), $blockid, $id));
} catch (backup_task_exception $e) {
$a = stdClass();
$a->mid = $id;
$a->bid = $blockid;
$controller->log(get_string('error_block_for_module_not_found', 'backup', $a), backup::LOG_WARNING);
}
}
} catch (backup_task_exception $e) {
$controller->log(get_string('error_course_module_not_found', 'backup', $id), backup::LOG_WARNING);
}
}

Expand Down
2 changes: 2 additions & 0 deletions lang/en/backup.php
Expand Up @@ -105,6 +105,8 @@
$string['currentstage16'] = 'Complete';
$string['dependenciesenforced'] = 'Your settings have been altered due to unmet dependencies';
$string['enterasearch'] = 'Enter a search';
$string['error_block_for_module_not_found'] = 'Orphan block instance (id: {$a->bid}) for course module (id: {$a->mid}) found. This block will not be backed up';
$string['error_course_module_not_found'] = 'Orphan course module (id: {$a}) found. This module will not be backed up.';
$string['errorfilenamerequired'] = 'You must enter a valid filename for this backup';
$string['errorfilenamemustbezip'] = 'The filename you enter must be a ZIP file and have the .mbz extension';
$string['errorminbackup20version'] = 'This backup file has been created with one development version of Moodle backup ({$a->backup}). Minimum required is {$a->min}. Cannot be restored.';
Expand Down

0 comments on commit 543301a

Please sign in to comment.