diff --git a/src/Extensions/TwigTemplateContextExtension.php b/src/Extensions/TwigTemplateContextExtension.php index ce517356e..b81ab068f 100644 --- a/src/Extensions/TwigTemplateContextExtension.php +++ b/src/Extensions/TwigTemplateContextExtension.php @@ -7,6 +7,7 @@ use IO\Helper\EventDispatcher; use IO\Helper\TemplateContainer; use IO\Services\TemplateService; +use Plenty\Modules\ContentCache\Contracts\ContentCacheRepositoryContract; use Plenty\Plugin\Templates\Extensions\Twig_Extension; class TwigTemplateContextExtension extends Twig_Extension @@ -64,7 +65,14 @@ public function getGlobals(): array $context->init(TemplateService::$currentTemplateData); } - return ArrayHelper::toArray($context); + $contextArray = ArrayHelper::toArray($context); + if(is_null($contextArray)) { + /** @var ContentCacheRepositoryContract $contentCacheRepository */ + $contentCacheRepository = pluginApp(ContentCacheRepositoryContract::class); + $contentCacheRepository->disableCacheForResponse('Twig context could not be initialized'); + return []; + } + return $contextArray; } return [];