mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
Merge branch 'MDL-42815-master' of git://github.com/sammarshallou/moodle
This commit is contained in:
commit
438ee6ebdc
@ -130,6 +130,13 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
// Carry out actual backup.
|
||||
$backup->execute();
|
||||
|
||||
// Backup controller gets saved/loaded so the logger object changes and we
|
||||
// have to retrieve it.
|
||||
$logger = $backup->get_controller()->get_logger();
|
||||
while (!is_a($logger, 'core_backup_html_logger')) {
|
||||
$logger = $logger->get_next();
|
||||
}
|
||||
|
||||
// Get HTML from logger.
|
||||
$loghtml = $logger->get_html();
|
||||
|
||||
|
@ -107,7 +107,19 @@ class file_nested_element extends backup_nested_element {
|
||||
backup_file_manager::copy_file_moodle2backup($this->backupid, $values);
|
||||
} catch (file_exception $e) {
|
||||
$this->add_result(array('missing_files_in_pool' => true));
|
||||
$this->add_log('missing file in pool: ' . $e->debuginfo, backup::LOG_WARNING);
|
||||
|
||||
// Build helpful log message with all information necessary to identify
|
||||
// file location.
|
||||
$context = context::instance_by_id($values->contextid, IGNORE_MISSING);
|
||||
$contextname = '';
|
||||
if ($context) {
|
||||
$contextname = ' \'' . $context->get_context_name() . '\'';
|
||||
}
|
||||
$message = 'Missing file in pool: ' . $values->filepath . $values->filename .
|
||||
' (context ' . $values->contextid . $contextname . ', component ' .
|
||||
$values->component . ', filearea ' . $values->filearea . ', itemid ' .
|
||||
$values->itemid . ') [' . $e->debuginfo . ']';
|
||||
$this->add_log($message, backup::LOG_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -995,11 +995,7 @@ abstract class restore_dbops {
|
||||
if ($includesfiles) {
|
||||
// The file is not found in the backup.
|
||||
if (!file_exists($backuppath)) {
|
||||
$result = new stdClass();
|
||||
$result->code = 'file_missing_in_backup';
|
||||
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
|
||||
$result->level = backup::LOG_WARNING;
|
||||
$results[] = $result;
|
||||
$results[] = self::get_missing_file_result($file);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1028,11 +1024,7 @@ abstract class restore_dbops {
|
||||
$fs->create_file_from_storedfile($file_record, $foundfile->id);
|
||||
} else {
|
||||
// A matching existing file record was not found in the database.
|
||||
$result = new stdClass();
|
||||
$result->code = 'file_missing_in_backup';
|
||||
$result->message = sprintf('missing file %s%s in backup', $file->filepath, $file->filename);
|
||||
$result->level = backup::LOG_WARNING;
|
||||
$results[] = $result;
|
||||
$results[] = self::get_missing_file_result($file);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1063,6 +1055,22 @@ abstract class restore_dbops {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns suitable entry to include in log when there is a missing file.
|
||||
*
|
||||
* @param stdClass $file File definition
|
||||
* @return stdClass Log entry
|
||||
*/
|
||||
protected static function get_missing_file_result($file) {
|
||||
$result = new stdClass();
|
||||
$result->code = 'file_missing_in_backup';
|
||||
$result->message = 'Missing file in backup: ' . $file->filepath . $file->filename .
|
||||
' (old context ' . $file->contextid . ', component ' . $file->component .
|
||||
', filearea ' . $file->filearea . ', old itemid ' . $file->itemid . ')';
|
||||
$result->level = backup::LOG_WARNING;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one restoreid, create in DB all the users present
|
||||
* in backup_ids having newitemid = 0, as far as
|
||||
|
Loading…
x
Reference in New Issue
Block a user