From d01ac994b8230474aa0de6dbabcda40f28343a9d Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Mon, 1 Jul 2024 09:00:44 +0200 Subject: [PATCH] fix: added missing check on result, closes #3059 --- phpmyfaq/src/phpMyFAQ/Category.php | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Category.php b/phpmyfaq/src/phpMyFAQ/Category.php index f6ce14484a..b3ee5d9fab 100755 --- a/phpmyfaq/src/phpMyFAQ/Category.php +++ b/phpmyfaq/src/phpMyFAQ/Category.php @@ -379,24 +379,26 @@ public function getHomeCategories(): array $result = $this->config->getDb()->query($query); - while ($row = $this->config->getDb()->fetchArray($result)) { - $url = sprintf('%sindex.php?action=show&cat=%d', $this->config->getDefaultUrl(), $row['id']); - $link = new Link($url, $this->config); - $link->itemTitle = $row['name']; - if ('' === $row['image']) { - $image = ''; - } else { - $image = 'images/' . $row['image']; - } + if ($result) { + while ($row = $this->config->getDb()->fetchArray($result)) { + $url = sprintf('%sindex.php?action=show&cat=%d', $this->config->getDefaultUrl(), $row['id']); + $link = new Link($url, $this->config); + $link->itemTitle = $row['name']; + if ('' === $row['image']) { + $image = ''; + } else { + $image = 'images/' . $row['image']; + } - $category = [ - 'url' => Strings::htmlentities($link->toString()), - 'name' => $row['name'], - 'description' => $row['description'], - 'image' => $image - ]; + $category = [ + 'url' => Strings::htmlentities($link->toString()), + 'name' => $row['name'], + 'description' => $row['description'], + 'image' => $image + ]; - $categories[] = $category; + $categories[] = $category; + } } return $categories;