From 42142ae1c0f131c19f1096b5eec9f438ca611f7e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 28 May 2024 16:39:14 +0100 Subject: [PATCH] [11.x] Fixes exception rendering (#51587) * Cleans queries on job processed * Avoids double rendering * Removes temp variable --- .../Exceptions/Renderer/Listener.php | 6 +++ .../renderer/components/layout.blade.php | 6 +++ .../components/theme-swicher.blade.php | 37 ++++++++++--------- .../exceptions/renderer/show.blade.php | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php index d8102106b1d2..325fad4c20ac 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php @@ -4,6 +4,8 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\Events\QueryExecuted; +use Illuminate\Queue\Events\JobProcessed; +use Illuminate\Queue\Events\JobProcessing; use Laravel\Octane\Events\RequestReceived; use Laravel\Octane\Events\RequestTerminated; use Laravel\Octane\Events\TaskReceived; @@ -28,6 +30,10 @@ public function registerListeners(Dispatcher $events) { $events->listen(QueryExecuted::class, [$this, 'onQueryExecuted']); + $events->listen([JobProcessing::class, JobProcessed::class], function () { + $this->queries = []; + }); + if (isset($_SERVER['LARAVEL_OCTANE'])) { $events->listen([RequestReceived::class, TaskReceived::class, TickReceived::class, RequestTerminated::class], function () { $this->queries = []; diff --git a/src/Illuminate/Foundation/resources/exceptions/renderer/components/layout.blade.php b/src/Illuminate/Foundation/resources/exceptions/renderer/components/layout.blade.php index 2ef340ba0546..baa28929f580 100644 --- a/src/Illuminate/Foundation/resources/exceptions/renderer/components/layout.blade.php +++ b/src/Illuminate/Foundation/resources/exceptions/renderer/components/layout.blade.php @@ -38,6 +38,12 @@ hljs.initLineNumbersOnLoad() window.addEventListener('load', function() { + document.querySelectorAll('.renderer').forEach(function(element, index) { + if (index > 0) { + element.remove(); + } + }); + document.querySelector('.default-highlightable-code').style.display = 'block'; document.querySelectorAll('.highlightable-code').forEach(function(element) { diff --git a/src/Illuminate/Foundation/resources/exceptions/renderer/components/theme-swicher.blade.php b/src/Illuminate/Foundation/resources/exceptions/renderer/components/theme-swicher.blade.php index 387680179c78..110b7211204c 100644 --- a/src/Illuminate/Foundation/resources/exceptions/renderer/components/theme-swicher.blade.php +++ b/src/Illuminate/Foundation/resources/exceptions/renderer/components/theme-swicher.blade.php @@ -1,31 +1,34 @@
-
+