From 16f4f48449fc1c21bdb851d01d0ef791665f6448 Mon Sep 17 00:00:00 2001 From: Florian Heinze Date: Thu, 16 Dec 2021 20:12:20 +0100 Subject: [PATCH] BUGFIX: addContextualConsent needs to be more robust --- Classes/Eel/Helper/CookiePunch.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Classes/Eel/Helper/CookiePunch.php b/Classes/Eel/Helper/CookiePunch.php index 50f003f..9ee79de 100644 --- a/Classes/Eel/Helper/CookiePunch.php +++ b/Classes/Eel/Helper/CookiePunch.php @@ -116,17 +116,18 @@ public function blockTags(array $tagNames, string $markup, bool $enabled = true, * @param string $service * @return string */ - public function addContextualConsent( - string $service, - string $markup, - bool $isEnabled = true - ) { - $this->validateService($service); - if ($isEnabled) { - return '
' . $markup . "
"; - } else { - return $markup; + public function addContextualConsent(?string $service, string $markup, bool $isEnabled = true) { + // service can be null e.g. if nothing is selected for `Sandstorm.CookiePunch:Mixin.ConsentServices` + // in the inspector + if($service) { + $this->validateService($service); + if ($isEnabled) { + return '
' . $markup . "
"; + } else { + return $markup; + } } + return $markup; } private function addNeverBlockAttribute(string $tag): string {