Issue #2194111 by sun: Error handler throws exception when service container is not (fully) available yet.

8.0.x
Alex Pott 2014-02-16 18:40:49 +00:00
parent e17552ab02
commit e71d749ecc
3 changed files with 12 additions and 2 deletions

View File

@ -1300,7 +1300,7 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG
// It is possible that the error handling will itself trigger an error. In that case, we could
// end up in an infinite loop. To avoid that, we implement a simple static semaphore.
if (!$in_error_state && function_exists('module_implements')) {
if (!$in_error_state && \Drupal::hasService('module_handler')) {
$in_error_state = TRUE;
// The user object may not exist in all conditions, so 0 is substituted if needed.

View File

@ -169,7 +169,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
}
}
if (\Drupal::request()->isXmlHttpRequest()) {
if (\Drupal::hasRequest() && \Drupal::request()->isXmlHttpRequest()) {
if ($fatal) {
if (error_displayable($error)) {
// When called from JavaScript, simply output the error message.

View File

@ -149,6 +149,16 @@ class Drupal {
return static::$container && static::$container->has($id);
}
/**
* Indicates if there is a currently active request object.
*
* @return bool
* TRUE if there is a currently active request object, FALSE otherwise.
*/
public static function hasRequest() {
return static::$container && static::$container->has('request') && static::$container->initialized('request') && static::$container->isScopeActive('request');
}
/**
* Retrieves the currently active request object.
*