From 312c8753ccf3c4f2ca4a2dc70a800f93ad72dc8d Mon Sep 17 00:00:00 2001 From: N3Cr0N Date: Sun, 23 Jun 2019 22:42:39 +0200 Subject: [PATCH] Update Whoops error handler to v2.4.0 --- composer.json | 2 +- composer.lock | 12 +-- vendor/composer/installed.json | 19 ++--- vendor/filp/whoops/CHANGELOG.md | 8 ++ .../whoops/src/Whoops/Exception/Frame.php | 6 +- .../whoops/src/Whoops/Exception/Inspector.php | 2 +- .../src/Whoops/Handler/PlainTextHandler.php | 56 ++++++++++++-- .../src/Whoops/Handler/PrettyPageHandler.php | 5 +- .../src/Whoops/Handler/XmlResponseHandler.php | 2 +- .../src/Whoops/Resources/css/whoops.base.css | 12 +-- .../views/frames_description.html.php | 10 +-- .../Whoops/Resources/views/header.html.php | 5 +- vendor/filp/whoops/src/Whoops/Run.php | 73 ++++++++++++++++--- .../whoops/src/Whoops/Util/SystemFacade.php | 4 +- .../whoops/src/Whoops/Util/TemplateHelper.php | 2 +- 15 files changed, 160 insertions(+), 58 deletions(-) diff --git a/composer.json b/composer.json index 46176b9..c30ae93 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ }, "require": { "php": ">=5.3.7", - "filp/whoops": "^2.3" + "filp/whoops": "^2.4" }, "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" diff --git a/composer.lock b/composer.lock index ed97234..ad151ec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a192dd654d096b52bfb16b28531e76e1", + "content-hash": "572390f8ad9a5e9df85476deeb0faf06", "packages": [ { "name": "filp/whoops", - "version": "2.3.1", + "version": "2.4.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7" + "reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/bc0fd11bc455cc20ee4b5edabc63ebbf859324c7", - "reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7", + "url": "https://api.github.com/repos/filp/whoops/zipball/1a1a1044ad00e285bd2825fac4c3a0443d90ad33", + "reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33", "shasum": "" }, "require": { @@ -65,7 +65,7 @@ "throwable", "whoops" ], - "time": "2018-10-23T09:00:00+00:00" + "time": "2019-06-23T09:00:00+00:00" }, { "name": "psr/log", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index b448b42..7f50e3d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -57,17 +57,17 @@ }, { "name": "filp/whoops", - "version": "2.3.1", - "version_normalized": "2.3.1.0", + "version": "2.4.0", + "version_normalized": "2.4.0.0", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7" + "reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/bc0fd11bc455cc20ee4b5edabc63ebbf859324c7", - "reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7", + "url": "https://api.github.com/repos/filp/whoops/zipball/1a1a1044ad00e285bd2825fac4c3a0443d90ad33", + "reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33", "shasum": "" }, "require": { @@ -83,7 +83,7 @@ "symfony/var-dumper": "Pretty print complex values better with var-dumper available", "whoops/soap": "Formats errors as SOAP responses" }, - "time": "2018-10-23T09:00:00+00:00", + "time": "2019-06-23T09:00:00+00:00", "type": "library", "extra": { "branch-alias": { @@ -124,12 +124,12 @@ "version_normalized": "1.1.0.0", "source": { "type": "git", - "url": "https://github.com/mikey179/vfsStream.git", + "url": "https://github.com/bovigo/vfsStream.git", "reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/fc0fe8f4d0b527254a2dc45f0c265567c881d07e", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/fc0fe8f4d0b527254a2dc45f0c265567c881d07e", "reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e", "shasum": "" }, @@ -825,7 +825,8 @@ "keywords": [ "mock", "xunit" - ] + ], + "abandoned": true }, { "name": "psr/log", diff --git a/vendor/filp/whoops/CHANGELOG.md b/vendor/filp/whoops/CHANGELOG.md index 1a872a1..9e078a9 100644 --- a/vendor/filp/whoops/CHANGELOG.md +++ b/vendor/filp/whoops/CHANGELOG.md @@ -1,3 +1,11 @@ +# 2.4.0 + +* Allow to prepend and append handlers. + +# 2.3.2 + +* Various fixes from the community. + # 2.3.1 * Prevent exception in Whoops when caught exception frame is not related to real file diff --git a/vendor/filp/whoops/src/Whoops/Exception/Frame.php b/vendor/filp/whoops/src/Whoops/Exception/Frame.php index 0aad546..f63e2a4 100644 --- a/vendor/filp/whoops/src/Whoops/Exception/Frame.php +++ b/vendor/filp/whoops/src/Whoops/Exception/Frame.php @@ -119,7 +119,11 @@ public function getFileContents() return null; } - $this->fileContentsCache = file_get_contents($filePath); + try { + $this->fileContentsCache = file_get_contents($filePath); + } catch (ErrorException $exception) { + // Internal file paths of PHP extensions cannot be opened + } } return $this->fileContentsCache; diff --git a/vendor/filp/whoops/src/Whoops/Exception/Inspector.php b/vendor/filp/whoops/src/Whoops/Exception/Inspector.php index 96cb9b5..04f72df 100644 --- a/vendor/filp/whoops/src/Whoops/Exception/Inspector.php +++ b/vendor/filp/whoops/src/Whoops/Exception/Inspector.php @@ -252,7 +252,7 @@ protected function getTrace($e) } if (!extension_loaded('xdebug') || !xdebug_is_enabled()) { - return []; + return $traces; } // Use xdebug to get the full stack trace and remove the shutdown handler stack trace diff --git a/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php b/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php index 2f5be90..192d0ff 100644 --- a/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php +++ b/vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php @@ -46,6 +46,11 @@ class PlainTextHandler extends Handler */ private $traceFunctionArgsOutputLimit = 1024; + /** + * @var bool + */ + private $addPreviousToOutput = true; + /** * @var bool */ @@ -114,6 +119,21 @@ public function addTraceToOutput($addTraceToOutput = null) return $this; } + /** + * Add previous exceptions to output. + * @param bool|null $addPreviousToOutput + * @return bool|$this + */ + public function addPreviousToOutput($addPreviousToOutput = null) + { + if (func_num_args() == 0) { + return $this->addPreviousToOutput; + } + + $this->addPreviousToOutput = (bool) $addPreviousToOutput; + return $this; + } + /** * Add error trace function arguments to output. * Set to True for all frame args, or integer for the n first frame args. @@ -151,14 +171,18 @@ public function setTraceFunctionArgsOutputLimit($traceFunctionArgsOutputLimit) public function generateResponse() { $exception = $this->getException(); - return sprintf( - "%s: %s in file %s on line %d%s\n", - get_class($exception), - $exception->getMessage(), - $exception->getFile(), - $exception->getLine(), - $this->getTraceOutput() - ); + $message = $this->getExceptionOutput($exception); + + if ($this->addPreviousToOutput) { + $previous = $exception->getPrevious(); + while ($previous) { + $message .= "\n\nCaused by\n" . $this->getExceptionOutput($previous); + $previous = $previous->getPrevious(); + } + } + + + return $message . $this->getTraceOutput() . "\n"; } /** @@ -284,6 +308,22 @@ private function getTraceOutput() return $response; } + /** + * Get the exception as plain text. + * @param \Throwable $exception + * @return string + */ + private function getExceptionOutput($exception) + { + return sprintf( + "%s: %s in file %s on line %d", + get_class($exception), + $exception->getMessage(), + $exception->getFile(), + $exception->getLine() + ); + } + /** * @return int */ diff --git a/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php b/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php index 9f0b655..d958512 100644 --- a/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php +++ b/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php @@ -97,6 +97,7 @@ class PrettyPageHandler extends Handler "idea" => "idea://open?file=%file&line=%line", "vscode" => "vscode://file/%file:%line", "atom" => "atom://core/open/file?filename=%file&line=%line", + "espresso" => "x-espresso://open?filepath=%file&lines=%line", ]; /** @@ -391,7 +392,7 @@ public function handleUnconditionally($value = null) * return "http://stackoverflow.com"; * }); * @param string $identifier - * @param string $resolver + * @param string|callable $resolver */ public function addEditor($identifier, $resolver) { @@ -704,7 +705,7 @@ private function masked(array $superGlobal, $superGlobalName) $values = $superGlobal; foreach ($blacklisted as $key) { - if (isset($superGlobal[$key])) { + if (isset($superGlobal[$key]) && is_string($superGlobal[$key])) { $values[$key] = str_repeat('*', strlen($superGlobal[$key])); } } diff --git a/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php b/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php index 0d0a577..decbbfa 100644 --- a/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php +++ b/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php @@ -47,7 +47,7 @@ public function handle() ), ]; - echo $this->toXml($response); + echo self::toXml($response); return Handler::QUIT; } diff --git a/vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css b/vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css index b86e2ae..d67499e 100644 --- a/vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css +++ b/vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css @@ -12,6 +12,11 @@ body { text-decoration: none; } +.Whoops.container { + position: relative; + z-index: 9999999999; +} + .panel { overflow-y: scroll; height: 100%; @@ -414,12 +419,9 @@ pre:not(.prettyprinted) { display: none; } -#copy-button { +.rightButton { cursor: pointer; border: 0; -} - -.clipboard { opacity: .8; background: none; @@ -431,7 +433,7 @@ pre:not(.prettyprinted) { outline: none !important; } - .clipboard:hover { + .rightButton:hover { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.3); } diff --git a/vendor/filp/whoops/src/Whoops/Resources/views/frames_description.html.php b/vendor/filp/whoops/src/Whoops/Resources/views/frames_description.html.php index e32cf88..5d32f71 100644 --- a/vendor/filp/whoops/src/Whoops/Resources/views/frames_description.html.php +++ b/vendor/filp/whoops/src/Whoops/Resources/views/frames_description.html.php @@ -1,14 +1,8 @@
- - + Application frames (countIsApplication() ?>) - - - - Application frames (countIsApplication() ?>) - - + All frames () diff --git a/vendor/filp/whoops/src/Whoops/Resources/views/header.html.php b/vendor/filp/whoops/src/Whoops/Resources/views/header.html.php index aefbeac..2f2d90f 100644 --- a/vendor/filp/whoops/src/Whoops/Resources/views/header.html.php +++ b/vendor/filp/whoops/src/Whoops/Resources/views/header.html.php @@ -86,8 +86,11 @@ escape($plain_exception) ?> - +
diff --git a/vendor/filp/whoops/src/Whoops/Run.php b/vendor/filp/whoops/src/Whoops/Run.php index 1d51f1c..cfaaa5e 100644 --- a/vendor/filp/whoops/src/Whoops/Run.php +++ b/vendor/filp/whoops/src/Whoops/Run.php @@ -29,7 +29,7 @@ final class Run implements RunInterface /** * @var HandlerInterface[] */ - private $handlerStack = []; + private $handlerQueue = []; private $silencedPatterns = []; @@ -41,13 +41,52 @@ public function __construct(SystemFacade $system = null) } /** - * Pushes a handler to the end of the stack + * Prepends a handler to the start of the queue * * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface * @param Callable|HandlerInterface $handler * @return Run + * @deprecated use appendHandler and prependHandler instead */ public function pushHandler($handler) + { + return $this->prependHandler($handler); + } + + /** + * Appends a handler to the end of the queue + * + * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface + * @param Callable|HandlerInterface $handler + * @return Run + */ + public function appendHandler($handler) + { + array_push($this->handlerQueue, $this->resolveHandler($handler)); + return $this; + } + + /** + * Prepends a handler to the start of the queue + * + * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface + * @param Callable|HandlerInterface $handler + * @return Run + */ + public function prependHandler($handler) + { + array_unshift($this->handlerQueue, $this->resolveHandler($handler)); + return $this; + } + + /** + * Create a CallbackHandler from callable and throw if handler is invalid + * + * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface + * @param Callable|HandlerInterface $handler + * @return HandlerInterface + */ + private function resolveHandler($handler) { if (is_callable($handler)) { $handler = new CallbackHandler($handler); @@ -55,43 +94,52 @@ public function pushHandler($handler) if (!$handler instanceof HandlerInterface) { throw new InvalidArgumentException( - "Argument to " . __METHOD__ . " must be a callable, or instance of " + "Argument to " . __METHOD__ . " must be a callable, or instance of " . "Whoops\\Handler\\HandlerInterface" ); } - $this->handlerStack[] = $handler; - return $this; + return $handler; } /** - * Removes the last handler in the stack and returns it. + * Removes the last handler in the queue and returns it. * Returns null if there"s nothing else to pop. * @return null|HandlerInterface */ public function popHandler() { - return array_pop($this->handlerStack); + return array_pop($this->handlerQueue); + } + + /** + * Removes the first handler in the queue and returns it. + * Returns null if there"s nothing else to shift. + * @return null|HandlerInterface + */ + public function shiftHandler() + { + return array_shift($this->handlerQueue); } /** * Returns an array with all handlers, in the - * order they were added to the stack. + * order they were added to the queue. * @return array */ public function getHandlers() { - return $this->handlerStack; + return $this->handlerQueue; } /** - * Clears all handlers in the handlerStack, including + * Clears all handlers in the handlerQueue, including * the default PrettyPage handler. * @return Run */ public function clearHandlers() { - $this->handlerStack = []; + $this->handlerQueue = []; return $this; } @@ -260,7 +308,7 @@ public function handleException($exception) $handlerResponse = null; $handlerContentType = null; - foreach (array_reverse($this->handlerStack) as $handler) { + foreach ($this->handlerQueue as $handler) { $handler->setRun($this); $handler->setInspector($inspector); $handler->setException($exception); @@ -375,6 +423,7 @@ public function handleShutdown() if ($error && Misc::isLevelFatal($error['type'])) { // If there was a fatal error, // it was not handled in handleError yet. + $this->allowQuit = false; $this->handleError( $error['type'], $error['message'], diff --git a/vendor/filp/whoops/src/Whoops/Util/SystemFacade.php b/vendor/filp/whoops/src/Whoops/Util/SystemFacade.php index cc82e7f..fb1bc28 100644 --- a/vendor/filp/whoops/src/Whoops/Util/SystemFacade.php +++ b/vendor/filp/whoops/src/Whoops/Util/SystemFacade.php @@ -26,9 +26,9 @@ public function startOutputBuffering() */ public function setErrorHandler(callable $handler, $types = 'use-php-defaults') { - // Workaround for PHP 5.5 + // Since PHP 5.4 the constant E_ALL contains all errors (even E_STRICT) if ($types === 'use-php-defaults') { - $types = E_ALL | E_STRICT; + $types = E_ALL; } return set_error_handler($handler, $types); } diff --git a/vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php b/vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php index 00f6ae4..9c7cec2 100644 --- a/vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php +++ b/vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php @@ -104,7 +104,7 @@ public function breakOnDelimiter($delimiter, $s) { $parts = explode($delimiter, $s); foreach ($parts as &$part) { - $part = '
' . $part . '
'; + $part = '' . $part . ''; } return implode($delimiter, $parts);