From 861d7163f66642389c4e4a2d35d7f7246c9f25d8 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 12 Feb 2021 10:10:58 -0500 Subject: [PATCH] Add WireShutdown::fatalError() hookable method to enable hooking fatal errors --- wire/core/WireShutdown.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wire/core/WireShutdown.php b/wire/core/WireShutdown.php index fbb8842b..0807ef75 100644 --- a/wire/core/WireShutdown.php +++ b/wire/core/WireShutdown.php @@ -8,6 +8,8 @@ * Look for errors at shutdown and log them, plus echo the error if the page is editable * * https://processwire.com + * + * @method void fatalError(array $error) * */ @@ -471,6 +473,15 @@ class WireShutdown extends Wire { return $out === $token ? false : true; } + /** + * Hook called when fatal error received by shutdown() + * + * @param array $error + * @since 3.0.173 + * + */ + protected function ___fatalError($error) { } + /** * Shutdown function registered with PHP * @@ -484,6 +495,7 @@ class WireShutdown extends Wire { if(!$error) return true; if(!in_array($error['type'], $this->fatalTypes)) return true; + if(empty($this->error)) $this->fatalError($error); $this->error = $error; $this->prepareLabels(); $config = $this->config;