From bcce8218ffe2394b7836d61174058e7d1f7e8cd5 Mon Sep 17 00:00:00 2001 From: Malte Heyenga Date: Mon, 25 Mar 2019 10:34:59 +0100 Subject: [PATCH] check if flashmessages are available before passing them to foreach --- .../contao/modules/ModuleFlashMessages.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Resources/contao/modules/ModuleFlashMessages.php b/src/Resources/contao/modules/ModuleFlashMessages.php index 0c5417f..662d762 100644 --- a/src/Resources/contao/modules/ModuleFlashMessages.php +++ b/src/Resources/contao/modules/ModuleFlashMessages.php @@ -41,12 +41,16 @@ protected function compile() { $flashMessages = Flash::load(); $ids = []; - $encIds = []; - foreach($flashMessages as $flash){ - if(!$flash->autoDismiss) continue; - $ids[] = $flash->id; - $encIds[] = "\"$flash->id\""; - } + $encIds = []; + + if($flashMessages) { + foreach($flashMessages as $flash){ + if(!$flash->autoDismiss) continue; + $ids[] = $flash->id; + $encIds[] = "\"$flash->id\""; + } + } + $this->Template->flashMessages = $flashMessages; $this->Template->ids = $ids; $this->Template->encIds = $encIds;