From 0cb284699815dfaf8e00ea33bf8d5e85b7e1b4cd Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 15 Oct 2013 14:44:00 +0800 Subject: [PATCH] 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 540613d1826..cd2c3a08ee8 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -908,6 +908,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);