Skip to content

Commit

Permalink
fix: added missing check on result, closes #3059
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jul 1, 2024
1 parent ba32194 commit d01ac99
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions phpmyfaq/src/phpMyFAQ/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d01ac99

Please sign in to comment.