diff --git a/src/CoreBundle/Contao/Hooks/ContentElementCallback.php b/src/CoreBundle/Contao/Hooks/ContentElementCallback.php index 13c024b14..7001d1d8f 100644 --- a/src/CoreBundle/Contao/Hooks/ContentElementCallback.php +++ b/src/CoreBundle/Contao/Hooks/ContentElementCallback.php @@ -22,6 +22,7 @@ namespace MetaModels\CoreBundle\Contao\Hooks; +use Contao\CoreBundle\Exception\AccessDeniedException; use Contao\DC_Table; /** @@ -45,10 +46,15 @@ class ContentElementCallback extends AbstractContentElementAndModuleCallback */ public function buildFilterParameterList(DC_Table $dataContainer) { - if ( - null === ($currentRecord = $dataContainer->getCurrentRecord()) - || $currentRecord['type'] !== 'metamodel_content' - ) { + try { + if ( + null === ($currentRecord = $dataContainer->getCurrentRecord()) + || $currentRecord['type'] !== 'metamodel_content' + ) { + return; + } + } catch (AccessDeniedException $exception) { + // If the access is denied, we don't want to build filter parameters. return; } diff --git a/src/CoreBundle/Contao/Hooks/FilterContentElementCallback.php b/src/CoreBundle/Contao/Hooks/FilterContentElementCallback.php index 274ffef58..2abe00b73 100644 --- a/src/CoreBundle/Contao/Hooks/FilterContentElementCallback.php +++ b/src/CoreBundle/Contao/Hooks/FilterContentElementCallback.php @@ -19,6 +19,7 @@ namespace MetaModels\CoreBundle\Contao\Hooks; +use Contao\CoreBundle\Exception\AccessDeniedException; use Contao\DC_Table; /** @@ -36,13 +37,17 @@ final class FilterContentElementCallback extends AbstractContentElementAndModule /** Called from tl_content.onload_callback. */ public function buildFilterParameterList(DC_Table $dataContainer): void { - if ( - null === ($currentRecord = $dataContainer->getCurrentRecord()) - || $currentRecord['type'] !== 'metamodels_frontendfilter' - ) { + try { + if ( + null === ($currentRecord = $dataContainer->getCurrentRecord()) + || $currentRecord['type'] !== 'metamodels_frontendfilter' + ) { + return; + } + } catch (AccessDeniedException $exception) { + // If the access is denied, we don't want to build filter parameters. return; } - $this->buildFilterParamsFor($dataContainer, 'metamodels_frontendfilter'); } }