Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-25432 backup: Catching exception for orphan course modules and it…

…'s block (if any), and logging them, no exception will be thrown for this now.
  • Loading branch information...
commit 7e19c5e1f5054a2a0bac24cf581344213b413d8d 1 parent ad52027
Rajesh Taneja rajeshtaneja authored
23 backup/moodle2/backup_plan_builder.class.php
@@ -123,12 +123,23 @@ static protected function build_activity_plan($controller, $id) {
123 123
124 124 // Add the activity task, responsible for outputting
125 125 // all the module related information
126   - $plan->add_task(backup_factory::get_backup_activity_task($controller->get_format(), $id));
127   -
128   - // For the given activity, add as many block tasks as necessary
129   - $blockids = backup_plan_dbops::get_blockids_from_moduleid($id);
130   - foreach ($blockids as $blockid) {
131   - $plan->add_task(backup_factory::get_backup_block_task($controller->get_format(), $blockid, $id));
  126 + try {
  127 + $plan->add_task(backup_factory::get_backup_activity_task($controller->get_format(), $id));
  128 +
  129 + // For the given activity, add as many block tasks as necessary
  130 + $blockids = backup_plan_dbops::get_blockids_from_moduleid($id);
  131 + foreach ($blockids as $blockid) {
  132 + try {
  133 + $plan->add_task(backup_factory::get_backup_block_task($controller->get_format(), $blockid, $id));
  134 + } catch (backup_task_exception $e) {
  135 + $a = stdClass();
  136 + $a->mid = $id;
  137 + $a->bid = $blockid;
  138 + $controller->log(get_string('error_block_for_module_not_found', 'backup', $a), backup::LOG_WARNING);
  139 + }
  140 + }
  141 + } catch (backup_task_exception $e) {
  142 + $controller->log(get_string('error_course_module_not_found', 'backup', $id), backup::LOG_WARNING);
132 143 }
133 144 }
134 145
2  lang/en/backup.php
@@ -106,6 +106,8 @@
106 106 $string['currentstage16'] = 'Complete';
107 107 $string['dependenciesenforced'] = 'Your settings have been altered due to unmet dependencies';
108 108 $string['enterasearch'] = 'Enter a search';
  109 +$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';
  110 +$string['error_course_module_not_found'] = 'Orphan course module (id: {$a}) found. This module will not be backed up.';
109 111 $string['errorfilenamerequired'] = 'You must enter a valid filename for this backup';
110 112 $string['errorfilenamemustbezip'] = 'The filename you enter must be a ZIP file and have the .mbz extension';
111 113 $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.';

0 comments on commit 7e19c5e

Please sign in to comment.
Something went wrong with that request. Please try again.