From d848e3fe7099d72c12da90f6b1030f070014f05f Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 4 Jul 2013 08:51:13 +0200 Subject: [PATCH] Fix PHP warning on empty news table Fixes #358 --- public/include/pages/home.inc.php | 8 +++++--- public/include/pages/news.inc.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/include/pages/home.inc.php b/public/include/pages/home.inc.php index 2d0f5b23..ea4bd8fb 100644 --- a/public/include/pages/home.inc.php +++ b/public/include/pages/home.inc.php @@ -8,9 +8,11 @@ use \Michelf\Markdown; // Fetch active news to display $aNews = $news->getAllActive(); -foreach ($aNews as $key => $aData) { - // Transform Markdown content to HTML - $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); +if (is_array($aNews)) { + foreach ($aNews as $key => $aData) { + // Transform Markdown content to HTML + $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); + } } // Load news entries for Desktop site and unauthenticated users diff --git a/public/include/pages/news.inc.php b/public/include/pages/news.inc.php index 38e1022d..127b1775 100644 --- a/public/include/pages/news.inc.php +++ b/public/include/pages/news.inc.php @@ -8,9 +8,11 @@ use \Michelf\Markdown; // Fetch active news to display $aNews = $news->getAllActive(); -foreach ($aNews as $key => $aData) { - // Transform Markdown content to HTML - $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); +if (is_array($aNews)) { + foreach ($aNews as $key => $aData) { + // Transform Markdown content to HTML + $aNews[$key]['content'] = Markdown::defaultTransform($aData['content']); + } } // Tempalte specifics