MDL-38196 Backup/restore: Display log if non-empty

When doing a backup or restore operation with the normal user interface,
if there is anything in the backup/restore log, it will now be displayed
at the end of the process below the Continue button.

If you have developer debugging enabled, it sets the display level to
LOG_DEBUG and there will always be content in the log. Otherwise, it
uses LOG_INFO which generally means the log is empty, and nothing
displays (no visible change for users).
This commit is contained in:
sam marshall 2013-09-10 13:25:04 +01:00
parent 56cc9b387e
commit 77b3d9dfdf
15 changed files with 220 additions and 73 deletions

View file

@ -100,12 +100,24 @@ if ($backup->enforce_changed_dependencies()) {
debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
}
$loghtml = '';
if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
// Display an extra progress bar so that we can show the progress first.
// Display an extra backup step bar so that we can show the 'processing' step first.
echo html_writer::start_div('', array('id' => 'executionprogress'));
echo $renderer->progress_bar($backup->get_progress_bar());
$backup->get_controller()->set_progress(new core_backup_display_progress());
// Prepare logger and add to end of chain.
$logger = new core_backup_html_logger($CFG->debugdeveloper ? backup::LOG_DEBUG : backup::LOG_INFO);
$backup->get_controller()->add_logger($logger);
// Carry out actual backup.
$backup->execute();
// Get HTML from logger.
$loghtml = $logger->get_html();
// Hide the progress display and first backup step bar (the 'finished' step will show next).
echo html_writer::end_div();
echo html_writer::script('document.getElementById("executionprogress").style.display = "none";');
} else {
@ -116,4 +128,10 @@ echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
// Display log data if there was any.
if ($loghtml != '') {
echo $renderer->log_display($loghtml);
}
echo $OUTPUT->footer();