From e44008b8c74e514d96cd82f3d23438f126bf014d Mon Sep 17 00:00:00 2001 From: Najdanovic Ivan Date: Mon, 8 Nov 2021 18:08:57 +0100 Subject: [PATCH 1/2] Toolbar - Make it possible to turn off var data collection --- app/Config/Toolbar.php | 12 ++++++++++++ system/Debug/Toolbar.php | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/app/Config/Toolbar.php b/app/Config/Toolbar.php index 16a37e83c2b8..7183e1336a28 100644 --- a/app/Config/Toolbar.php +++ b/app/Config/Toolbar.php @@ -44,6 +44,18 @@ class Toolbar extends BaseConfig Events::class, ]; + /** + * -------------------------------------------------------------------------- + * Collect Var Data + * -------------------------------------------------------------------------- + * + * If set to false var data from the views will not be colleted. Usefull to + * avoid high memory usage when there are lots of data passed to the view. + * + * @var bool + */ + public $collectVarData = true; + /** * -------------------------------------------------------------------------- * Max History diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index b951e2ed9658..e3cc5b68fce4 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -310,6 +310,10 @@ protected function structureTimelineData(array $elements): array */ protected function collectVarData(): array { + if (! $this->config->collectVarData) { + return []; + } + $data = []; foreach ($this->collectors as $collector) { From 395f71fad77eb1bc192417b1b87fe1ffe34a509d Mon Sep 17 00:00:00 2001 From: Najdanovic Ivan Date: Wed, 10 Nov 2021 01:05:07 +0100 Subject: [PATCH 2/2] Update system/Debug/Toolbar.php Co-authored-by: Lonnie Ezell --- system/Debug/Toolbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index e3cc5b68fce4..3502ae877caf 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -310,7 +310,7 @@ protected function structureTimelineData(array $elements): array */ protected function collectVarData(): array { - if (! $this->config->collectVarData) { + if (! ($this->config->collectVarData ?? true)) { return []; }