From 62b6135c38dc8e69f9929ed332ccdf8bc829aca2 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 15 Oct 2013 13:53:59 +0800 Subject: [PATCH 1/2] MDL-34612 Restore: Gracefully handle empty section title while restoring --- backup/moodle2/restore_section_task.class.php | 3 +++ lang/en/backup.php | 1 + 2 files changed, 4 insertions(+) diff --git a/backup/moodle2/restore_section_task.class.php b/backup/moodle2/restore_section_task.class.php index 7550261e6a8..b46ed6b906a 100644 --- a/backup/moodle2/restore_section_task.class.php +++ b/backup/moodle2/restore_section_task.class.php @@ -161,6 +161,9 @@ class restore_section_task extends restore_task { $section_included = new restore_section_included_setting($settingname, base_setting::IS_BOOLEAN, true); if (is_number($this->info->title)) { $label = get_string('includesection', 'backup', $this->info->title); + } elseif (empty($this->info->title)) { // Don't throw error if title is empty, gracefully continue restore. + $this->log('Section title missing in backup for section id '.$this->info->sectionid, backup::LOG_WARNING, $this->name); + $label = get_string('unnamedsection', 'backup'); } else { $label = $this->info->title; } diff --git a/lang/en/backup.php b/lang/en/backup.php index f156fa954b9..18a34ff3719 100644 --- a/lang/en/backup.php +++ b/lang/en/backup.php @@ -262,6 +262,7 @@ $string['skipmodifprevhelp'] = 'Choose whether or not to skip courses that have $string['title'] = 'Title'; $string['totalcategorysearchresults'] = 'Total categories: {$a}'; $string['totalcoursesearchresults'] = 'Total courses: {$a}'; +$string['unnamedsection'] = 'Unnamed section'; $string['userinfo'] = 'Userinfo'; $string['module'] = 'Module'; $string['morecoursesearchresults'] = 'More than {$a} courses found, showing first {$a} results'; From 0daadaaeafc458cfa47ce682df0dc4089adb647e Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 15 Oct 2013 14:44:00 +0800 Subject: [PATCH 2/2] MDL-34612 Restore: Gracefully handle empty file contenthash while restoring --- backup/util/dbops/restore_dbops.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backup/util/dbops/restore_dbops.class.php b/backup/util/dbops/restore_dbops.class.php index 0d0155d64b9..f1f544315e3 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -976,6 +976,15 @@ abstract class restore_dbops { ); if (empty($file->repositoryid)) { + // If contenthash is empty then gracefully skip adding file. + if (empty($file->contenthash)) { + $result = new stdClass(); + $result->code = 'file_missing_in_backup'; + $result->message = sprintf('missing file (%s) contenthash in backup for component %s', $file->filename, $component); + $result->level = backup::LOG_WARNING; + $results[] = $result; + continue; + } // this is a regular file, it must be present in the backup pool $backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);