diff options
| author | 2022-11-07 08:35:33 +0100 | |
|---|---|---|
| committer | 2022-11-07 08:35:33 +0100 | |
| commit | 2c0f3fad2d1e175f3f384d0c9d8c4c189bcffc82 (patch) | |
| tree | 9f12f74eb37caffc66f056c4e9490191ebc5f54a | |
| parent | 5897487f2f29cd3f29b538919c57988f118461e7 (diff) | |
Avoid exception in searchById (#4822)
https://github.com/FreshRSS/FreshRSS/issues/4820
Not a root-cause fix though (cannot reproduce so far)
| -rw-r--r-- | app/Models/CategoryDAO.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index e098c65e4..20a92d52a 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -228,16 +228,16 @@ SQL; public function searchById($id) { $sql = 'SELECT * FROM `_category` WHERE id=:id'; $stm = $this->pdo->prepare($sql); - $stm->bindParam(':id', $id, PDO::PARAM_INT); - $stm->execute(); - $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $cat = self::daoToCategory($res); - - if (isset($cat[0])) { - return $cat[0]; - } else { - return null; + if ($stm && + $stm->bindParam(':id', $id, PDO::PARAM_INT) && + $stm->execute()) { + $res = $stm->fetchAll(PDO::FETCH_ASSOC); + $cat = self::daoToCategory($res); + if (isset($cat[0])) { + return $cat[0]; + } } + return null; } /** @return FreshRSS_Category|null|false */ |
