Commit 38d4a105 authored by catch's avatar catch

Issue #2176105 by sun: Installer catches exceptions and manually re-prints...

Issue #2176105 by sun: Installer catches exceptions and manually re-prints them; does not use error/exception handler.
parent abc74498
......@@ -116,9 +116,10 @@ function error_displayable($error = NULL) {
* TRUE if the error is fatal.
*/
function _drupal_log_error($error, $fatal = FALSE) {
$is_installer = drupal_installation_attempted();
// Initialize a maintenance theme if the bootstrap was not complete.
// Do it early because drupal_set_message() triggers a drupal_theme_initialize().
if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
if (!$is_installer && $fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
unset($GLOBALS['theme']);
if (!defined('MAINTENANCE_MODE')) {
define('MAINTENANCE_MODE', 'error');
......@@ -215,14 +216,20 @@ function _drupal_log_error($error, $fatal = FALSE) {
// We fallback to a maintenance page at this point, because the page generation
// itself can generate errors.
// Should not translate the string to avoid errors producing more errors.
$output = theme('maintenance_page', array('content' => 'The website has encountered an error. Please try again later.'));
$response = new Response($output, 500);
if ($fatal) {
$response->setStatusCode(500, '500 Service unavailable (with message)');
$message = 'The website has encountered an error. Please try again later.';
if ($is_installer) {
// install_display_output() prints the output and ends script execution.
install_display_output($message, $GLOBALS['install_state']);
}
else {
$output = theme('maintenance_page', array('content' => $message));
}
return $response;
$response = new Response($output, 500);
$response->setStatusCode(500, '500 Service unavailable (with message)');
// An exception must halt script execution.
$response->send();
exit;
}
}
}
......
......@@ -88,24 +88,14 @@ function install_drupal($settings = array()) {
// installation.
$interactive = empty($settings);
$install_state = $settings + array('interactive' => $interactive) + install_state_defaults();
try {
// Begin the page request. This adds information about the current state of
// the Drupal installation to the passed-in array.
install_begin_request($install_state);
// Based on the installation state, run the remaining tasks for this page
// request, and collect any output.
$output = install_run_tasks($install_state);
}
catch (Exception $e) {
// When an installation error occurs, either send the error to the web
// browser or pass on the exception so the calling script can use it.
if ($install_state['interactive']) {
install_display_output($e->getMessage(), $install_state);
}
else {
throw $e;
}
}
// Begin the page request. This adds information about the current state of
// the Drupal installation to the passed-in array.
install_begin_request($install_state);
// Based on the installation state, run the remaining tasks for this page
// request, and collect any output.
$output = install_run_tasks($install_state);
// After execution, all tasks might be complete, in which case
// $install_state['installation_finished'] is TRUE. In case the last task
// has been processed, remove the global $install_state, so other code can
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment