diff --git a/core/lib/Drupal/Core/Controller/ExceptionController.php b/core/lib/Drupal/Core/Controller/ExceptionController.php index af66226..06a89a8 100644 --- a/core/lib/Drupal/Core/Controller/ExceptionController.php +++ b/core/lib/Drupal/Core/Controller/ExceptionController.php @@ -18,6 +18,7 @@ use Drupal\Component\Utility\String; use Symfony\Component\Debug\Exception\FlattenException; use Drupal\Core\ContentNegotiation; +use Drupal\Core\Utility\Error; /** * This controller handles HTTP errors generated by the routing system. @@ -413,7 +414,8 @@ protected function decodeException(FlattenException $exception) { array_shift($backtrace); } } - $caller = $this->getLastCaller($backtrace); + + $caller = Error::getLastCaller($backtrace); return array( '%type' => $exception->getClass(), @@ -427,46 +429,4 @@ protected function decodeException(FlattenException $exception) { ); } - /** - * Gets the last caller from a backtrace. - * - * The last caller is not necessarily the first item in the backtrace. Rather, - * it is the first item in the backtrace that is a PHP userspace function, - * and not one of our debug functions. - * - * @param $backtrace - * A standard PHP backtrace. - * - * @return array - * An associative array with keys 'file', 'line' and 'function'. - */ - protected function getLastCaller($backtrace) { - // Ignore black listed error handling functions. - $blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler'); - - // Errors that occur inside PHP internal functions do not generate - // information about file and line. - while (($backtrace && !isset($backtrace[0]['line'])) || - (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) { - array_shift($backtrace); - } - - // The first trace is the call itself. - // It gives us the line and the file of the last call. - $call = $backtrace[0]; - - // The second call give us the function where the call originated. - if (isset($backtrace[1])) { - if (isset($backtrace[1]['class'])) { - $call['function'] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()'; - } - else { - $call['function'] = $backtrace[1]['function'] . '()'; - } - } - else { - $call['function'] = 'main()'; - } - return $call; - } }