Issue #2159459 by sun: Rebuild script triggers errors in error handler, fails to rebuild container.

8.0.x
catch 2013-12-30 17:58:07 +00:00
parent 7240b39bff
commit f8d09132da
2 changed files with 19 additions and 6 deletions

View File

@ -373,12 +373,14 @@ function format_backtrace(array $backtrace) {
else { else {
$call['function'] = 'main'; $call['function'] = 'main';
} }
foreach ($trace['args'] as $arg) { if (isset($trace['args'])) {
if (is_scalar($arg)) { foreach ($trace['args'] as $arg) {
$call['args'][] = is_string($arg) ? '\'' . filter_xss($arg) . '\'' : $arg; if (is_scalar($arg)) {
} $call['args'][] = is_string($arg) ? '\'' . filter_xss($arg) . '\'' : $arg;
else { }
$call['args'][] = ucfirst(gettype($arg)); else {
$call['args'][] = ucfirst(gettype($arg));
}
} }
} }
$return .= $call['function'] . '(' . implode(', ', $call['args']) . ")\n"; $return .= $call['function'] . '(' . implode(', ', $call['args']) . ")\n";

View File

@ -34,6 +34,12 @@ function drupal_var_export($var, $prefix = '') {
* @see rebuild.php * @see rebuild.php
*/ */
function drupal_rebuild() { function drupal_rebuild() {
// Remove Drupal's error and exception handlers; they rely on a working
// service container and other subsystems and will only cause a fatal error
// that hides the actual error.
restore_error_handler();
restore_exception_handler();
// drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL) will build a new kernel. This // drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL) will build a new kernel. This
// comes before DRUPAL_BOOTSTRAP_PAGE_CACHE. // comes before DRUPAL_BOOTSTRAP_PAGE_CACHE.
PhpStorageFactory::get('service_container')->deleteAll(); PhpStorageFactory::get('service_container')->deleteAll();
@ -50,4 +56,9 @@ function drupal_rebuild() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches(); drupal_flush_all_caches();
// Restore Drupal's error and exception handlers.
// @see _drupal_bootstrap_configuration()
set_error_handler('_drupal_error_handler');
set_exception_handler('_drupal_exception_handler');
} }