From 0afa8a43d51af8022dda751993710ebfff358f36 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 16:11:43 +0900 Subject: [PATCH] fix: DebugBar initializes shared renderer instance A dev cannot create shared renderer instance. --- system/Debug/Toolbar/Collectors/Views.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index fae3385fffbc..2e036ff19c85 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -60,9 +60,9 @@ class Views extends BaseCollector protected $title = 'Views'; /** - * Instance of the Renderer service + * Instance of the shared Renderer service * - * @var RendererInterface + * @var RendererInterface|null */ protected $viewer; @@ -73,12 +73,9 @@ class Views extends BaseCollector */ protected $views = []; - /** - * Constructor. - */ - public function __construct() + private function getViewer(): void { - $this->viewer = Services::renderer(); + $this->viewer ??= Services::renderer(); } /** @@ -87,6 +84,8 @@ public function __construct() */ protected function formatTimelineData(): array { + $this->getViewer(); + $data = []; $rows = $this->viewer->getPerformanceData(); @@ -121,8 +120,9 @@ protected function formatTimelineData(): array */ public function getVarData(): array { - return [ + $this->getViewer(); + return [ 'View Data' => $this->viewer->getData(), ]; } @@ -132,6 +132,8 @@ public function getVarData(): array */ public function getBadgeValue(): int { + $this->getViewer(); + return count($this->viewer->getPerformanceData()); }