aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-09-11 17:14:53 +0200
committerGravatar GitHub <noreply@github.com> 2024-09-11 17:14:53 +0200
commitdfac9f5813df7d4c7c812c381364c8898333f559 (patch)
tree978496d0a8d8b0d6b5dbe836c6829296133b337c /app/Models
parent31c8846791d4b5316fbc790202f79545c012f9c2 (diff)
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions * Uniformisation
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/CategoryDAO.php18
-rw-r--r--app/Models/CategoryDAOSQLite.php2
-rw-r--r--app/Models/DatabaseDAO.php4
-rw-r--r--app/Models/DatabaseDAOSQLite.php4
-rw-r--r--app/Models/Entry.php66
-rw-r--r--app/Models/EntryDAO.php67
-rw-r--r--app/Models/EntryDAOSQLite.php14
-rw-r--r--app/Models/Feed.php10
-rw-r--r--app/Models/FeedDAO.php38
-rw-r--r--app/Models/FeedDAOSQLite.php2
-rw-r--r--app/Models/FormAuth.php2
-rw-r--r--app/Models/LogDAO.php2
-rw-r--r--app/Models/TagDAO.php20
-rw-r--r--app/Models/Themes.php4
-rw-r--r--app/Models/View.php6
-rw-r--r--app/Models/ViewStats.php2
16 files changed, 129 insertions, 132 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index b101f0b3f..2e9892df9 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -12,7 +12,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
$stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT);
$stm->bindValue(':name', 'Uncategorized');
}
- return $stm && $stm->execute();
+ return $stm !== false && $stm->execute();
}
protected function addColumn(string $name): bool {
@@ -126,7 +126,7 @@ SQL;
$catId = $this->pdo->lastInsertId('`_category_id_seq`');
return $catId === false ? false : (int)$catId;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->addCategory($valuesTmp);
}
@@ -137,7 +137,7 @@ SQL;
public function addCategoryObject(FreshRSS_Category $category): int|false {
$cat = $this->searchByName($category->name());
- if (!$cat) {
+ if ($cat === null) {
$values = [
'kind' => $category->kind(),
'name' => $category->name(),
@@ -175,7 +175,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->updateCategory($id, $valuesTmp);
}
@@ -196,7 +196,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -211,7 +211,7 @@ SQL;
if ($stm !== false && $stm->bindParam(':id', $id, PDO::PARAM_INT) && $stm->execute()) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -290,7 +290,7 @@ SQL;
* 'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'category'?:int,'website'?:string,'priority'?:int,'error'?:int|bool,'attributes'?:string,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $res */
return self::daoToCategoriesPrepopulated($res);
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->listCategories($prePopulateFeeds, $details);
}
@@ -315,7 +315,7 @@ SQL;
$stm->execute()) {
return self::daoToCategories($stm->fetchAll(PDO::FETCH_ASSOC));
} else {
- $info = $stm ? $stm->errorInfo() : $this->pdo->errorInfo();
+ $info = $stm !== false ? $stm->errorInfo() : $this->pdo->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->listCategoriesOrderUpdate($defaultCacheDuration, $limit);
}
@@ -362,7 +362,7 @@ SQL;
$catId = $this->pdo->lastInsertId('`_category_id_seq`');
return $catId === false ? false : (int)$catId;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
diff --git a/app/Models/CategoryDAOSQLite.php b/app/Models/CategoryDAOSQLite.php
index 4aaac07a8..d13c52550 100644
--- a/app/Models/CategoryDAOSQLite.php
+++ b/app/Models/CategoryDAOSQLite.php
@@ -6,7 +6,7 @@ class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO {
/** @param array<int|string> $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {
- if ($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) {
+ if (($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) !== false) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
foreach (['kind', 'lastUpdate', 'error', 'attributes'] as $column) {
if (!in_array($column, $columns, true)) {
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index ba0ee3e79..c46c91525 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -242,9 +242,9 @@ SQL;
foreach ($tables as $table) {
$sql = 'OPTIMIZE TABLE `_' . $table . '`'; //MySQL
$stm = $this->pdo->query($sql);
- if ($stm == false || $stm->fetchAll(PDO::FETCH_ASSOC) == false) {
+ if ($stm === false || $stm->fetchAll(PDO::FETCH_ASSOC) == false) {
$ok = false;
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
}
}
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
index 9380df094..231616f49 100644
--- a/app/Models/DatabaseDAOSQLite.php
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -10,7 +10,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
public function tablesAreCorrect(): bool {
$sql = "SELECT name FROM sqlite_master WHERE type='table'";
$stm = $this->pdo->query($sql);
- $res = $stm ? $stm->fetchAll(PDO::FETCH_ASSOC) : false;
+ $res = $stm !== false ? $stm->fetchAll(PDO::FETCH_ASSOC) : false;
if ($res === false) {
return false;
}
@@ -35,7 +35,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
public function getSchema(string $table): array {
$sql = 'PRAGMA table_info(' . $table . ')';
$stm = $this->pdo->query($sql);
- return $stm ? $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC) ?: []) : [];
+ return $stm !== false ? $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC) ?: []) : [];
}
#[\Override]
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 968e81499..35d1bed42 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -590,83 +590,83 @@ HTML;
} elseif ($filter instanceof FreshRSS_Search) {
// Searches are combined by OR and are not recursive
$ok = true;
- if ($filter->getEntryIds()) {
+ if ($filter->getEntryIds() !== null) {
$ok &= in_array($this->id, $filter->getEntryIds(), true);
}
- if ($ok && $filter->getNotEntryIds()) {
+ if ($ok && $filter->getNotEntryIds() !== null) {
$ok &= !in_array($this->id, $filter->getNotEntryIds(), true);
}
- if ($ok && $filter->getMinDate()) {
+ if ($ok && $filter->getMinDate() !== null) {
$ok &= strnatcmp($this->id, $filter->getMinDate() . '000000') >= 0;
}
- if ($ok && $filter->getNotMinDate()) {
+ if ($ok && $filter->getNotMinDate() !== null) {
$ok &= strnatcmp($this->id, $filter->getNotMinDate() . '000000') < 0;
}
- if ($ok && $filter->getMaxDate()) {
+ if ($ok && $filter->getMaxDate() !== null) {
$ok &= strnatcmp($this->id, $filter->getMaxDate() . '000000') <= 0;
}
- if ($ok && $filter->getNotMaxDate()) {
+ if ($ok && $filter->getNotMaxDate() !== null) {
$ok &= strnatcmp($this->id, $filter->getNotMaxDate() . '000000') > 0;
}
- if ($ok && $filter->getMinPubdate()) {
+ if ($ok && $filter->getMinPubdate() !== null) {
$ok &= $this->date >= $filter->getMinPubdate();
}
- if ($ok && $filter->getNotMinPubdate()) {
+ if ($ok && $filter->getNotMinPubdate() !== null) {
$ok &= $this->date < $filter->getNotMinPubdate();
}
- if ($ok && $filter->getMaxPubdate()) {
+ if ($ok && $filter->getMaxPubdate() !== null) {
$ok &= $this->date <= $filter->getMaxPubdate();
}
- if ($ok && $filter->getNotMaxPubdate()) {
+ if ($ok && $filter->getNotMaxPubdate() !== null) {
$ok &= $this->date > $filter->getNotMaxPubdate();
}
- if ($ok && $filter->getFeedIds()) {
+ if ($ok && $filter->getFeedIds() !== null) {
$ok &= in_array($this->feedId, $filter->getFeedIds(), true);
}
- if ($ok && $filter->getNotFeedIds()) {
+ if ($ok && $filter->getNotFeedIds() !== null) {
$ok &= !in_array($this->feedId, $filter->getNotFeedIds(), true);
}
- if ($ok && $filter->getAuthor()) {
+ if ($ok && $filter->getAuthor() !== null) {
foreach ($filter->getAuthor() as $author) {
$ok &= stripos(implode(';', $this->authors), $author) !== false;
}
}
- if ($ok && $filter->getAuthorRegex()) {
+ if ($ok && $filter->getAuthorRegex() !== null) {
foreach ($filter->getAuthorRegex() as $author) {
$ok &= preg_match($author, implode("\n", $this->authors)) === 1;
}
}
- if ($ok && $filter->getNotAuthor()) {
+ if ($ok && $filter->getNotAuthor() !== null) {
foreach ($filter->getNotAuthor() as $author) {
$ok &= stripos(implode(';', $this->authors), $author) === false;
}
}
- if ($ok && $filter->getNotAuthorRegex()) {
+ if ($ok && $filter->getNotAuthorRegex() !== null) {
foreach ($filter->getNotAuthorRegex() as $author) {
$ok &= preg_match($author, implode("\n", $this->authors)) === 0;
}
}
- if ($ok && $filter->getIntitle()) {
+ if ($ok && $filter->getIntitle() !== null) {
foreach ($filter->getIntitle() as $title) {
$ok &= stripos($this->title, $title) !== false;
}
}
- if ($ok && $filter->getIntitleRegex()) {
+ if ($ok && $filter->getIntitleRegex() !== null) {
foreach ($filter->getIntitleRegex() as $title) {
$ok &= preg_match($title, $this->title) === 1;
}
}
- if ($ok && $filter->getNotIntitle()) {
+ if ($ok && $filter->getNotIntitle() !== null) {
foreach ($filter->getNotIntitle() as $title) {
$ok &= stripos($this->title, $title) === false;
}
}
- if ($ok && $filter->getNotIntitleRegex()) {
+ if ($ok && $filter->getNotIntitleRegex() !== null) {
foreach ($filter->getNotIntitleRegex() as $title) {
$ok &= preg_match($title, $this->title) === 0;
}
}
- if ($ok && $filter->getTags()) {
+ if ($ok && $filter->getTags() !== null) {
foreach ($filter->getTags() as $tag2) {
$found = false;
foreach ($this->tags as $tag1) {
@@ -679,7 +679,7 @@ HTML;
$ok &= $found;
}
}
- if ($ok && $filter->getTagsRegex()) {
+ if ($ok && $filter->getTagsRegex() !== null) {
foreach ($filter->getTagsRegex() as $tag2) {
$found = false;
foreach ($this->tags as $tag1) {
@@ -692,7 +692,7 @@ HTML;
$ok &= $found;
}
}
- if ($ok && $filter->getNotTags()) {
+ if ($ok && $filter->getNotTags() !== null) {
foreach ($filter->getNotTags() as $tag2) {
$found = false;
foreach ($this->tags as $tag1) {
@@ -705,7 +705,7 @@ HTML;
$ok &= !$found;
}
}
- if ($ok && $filter->getNotTagsRegex()) {
+ if ($ok && $filter->getNotTagsRegex() !== null) {
foreach ($filter->getNotTagsRegex() as $tag2) {
$found = false;
foreach ($this->tags as $tag1) {
@@ -718,42 +718,42 @@ HTML;
$ok &= !$found;
}
}
- if ($ok && $filter->getInurl()) {
+ if ($ok && $filter->getInurl() !== null) {
foreach ($filter->getInurl() as $url) {
$ok &= stripos($this->link, $url) !== false;
}
}
- if ($ok && $filter->getInurlRegex()) {
+ if ($ok && $filter->getInurlRegex() !== null) {
foreach ($filter->getInurlRegex() as $url) {
$ok &= preg_match($url, $this->link) === 1;
}
}
- if ($ok && $filter->getNotInurl()) {
+ if ($ok && $filter->getNotInurl() !== null) {
foreach ($filter->getNotInurl() as $url) {
$ok &= stripos($this->link, $url) === false;
}
}
- if ($ok && $filter->getNotInurlRegex()) {
+ if ($ok && $filter->getNotInurlRegex() !== null) {
foreach ($filter->getNotInurlRegex() as $url) {
$ok &= preg_match($url, $this->link) === 0;
}
}
- if ($ok && $filter->getSearch()) {
+ if ($ok && $filter->getSearch() !== null) {
foreach ($filter->getSearch() as $needle) {
$ok &= (stripos($this->title, $needle) !== false || stripos($this->content, $needle) !== false);
}
}
- if ($ok && $filter->getNotSearch()) {
+ if ($ok && $filter->getNotSearch() !== null) {
foreach ($filter->getNotSearch() as $needle) {
$ok &= (stripos($this->title, $needle) === false && stripos($this->content, $needle) === false);
}
}
- if ($ok && $filter->getSearchRegex()) {
+ if ($ok && $filter->getSearchRegex() !== null) {
foreach ($filter->getSearchRegex() as $needle) {
$ok &= (preg_match($needle, $this->title) === 1 || preg_match($needle, $this->content) === 1);
}
}
- if ($ok && $filter->getNotSearchRegex()) {
+ if ($ok && $filter->getNotSearchRegex() !== null) {
foreach ($filter->getNotSearchRegex() as $needle) {
$ok &= (preg_match($needle, $this->title) === 0 && preg_match($needle, $this->content) === 0);
}
@@ -1056,7 +1056,7 @@ HTML;
if ($category != null && $mode !== 'freshrss') {
$item['categories'][] = 'user/-/label/' . htmlspecialchars_decode($category->name(), ENT_QUOTES);
}
- if ($feed != null) {
+ if ($feed !== null) {
$item['origin']['htmlUrl'] = htmlspecialchars_decode($feed->website());
$item['origin']['title'] = $feed->name(); //EasyRSS
if ($mode === 'compat') {
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 6a00e2108..e22650f0d 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -138,10 +138,7 @@ SQL;
return false;
}
- /**
- * @var PDOStatement|null|false
- */
- private $addEntryPrepared = false;
+ private PDOStatement|null|false $addEntryPrepared = null;
/** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string,
* 'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes'?:null|string|array<string,mixed>} $valuesTmp */
@@ -158,7 +155,7 @@ SQL;
. ', :is_read, :is_favorite, :id_feed, :tags, :attributes)');
$this->addEntryPrepared = $this->pdo->prepare($sql);
}
- if ($this->addEntryPrepared) {
+ if ($this->addEntryPrepared != false) {
$this->addEntryPrepared->bindParam(':id', $valuesTmp['id']);
$valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 767);
$valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
@@ -200,10 +197,10 @@ SQL;
$this->addEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']);
}
}
- if ($this->addEntryPrepared && $this->addEntryPrepared->execute()) {
+ if ($this->addEntryPrepared != false && $this->addEntryPrepared->execute()) {
return true;
} else {
- $info = $this->addEntryPrepared == null ? $this->pdo->errorInfo() : $this->addEntryPrepared->errorInfo();
+ $info = $this->addEntryPrepared == false ? $this->pdo->errorInfo() : $this->addEntryPrepared->errorInfo();
if ($this->autoUpdateDb($info)) {
$this->addEntryPrepared = null;
return $this->addEntry($valuesTmp);
@@ -240,7 +237,7 @@ SQL;
return $result;
}
- private ?PDOStatement $updateEntryPrepared = null;
+ private PDOStatement|null|false $updateEntryPrepared = null;
/** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string,
* 'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes':array<string,mixed>} $valuesTmp */
@@ -252,7 +249,7 @@ SQL;
$valuesTmp['is_favorite'] = null;
}
- if ($this->updateEntryPrepared === null) {
+ if ($this->updateEntryPrepared == null) {
$sql = 'UPDATE `_entry` '
. 'SET title=:title, author=:author, '
. (static::isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content')
@@ -262,9 +259,9 @@ SQL;
. ', is_favorite=COALESCE(:is_favorite, is_favorite)'
. ', tags=:tags, attributes=:attributes '
. 'WHERE id_feed=:id_feed AND guid=:guid';
- $this->updateEntryPrepared = $this->pdo->prepare($sql) ?: null;
+ $this->updateEntryPrepared = $this->pdo->prepare($sql);
}
- if ($this->updateEntryPrepared) {
+ if ($this->updateEntryPrepared != false) {
$valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 767);
$valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
$this->updateEntryPrepared->bindParam(':guid', $valuesTmp['guid']);
@@ -309,10 +306,10 @@ SQL;
}
}
- if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute()) {
+ if ($this->updateEntryPrepared != false && $this->updateEntryPrepared->execute()) {
return true;
} else {
- $info = $this->updateEntryPrepared == null ? $this->pdo->errorInfo() : $this->updateEntryPrepared->errorInfo();
+ $info = $this->updateEntryPrepared == false ? $this->pdo->errorInfo() : $this->updateEntryPrepared->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->updateEntry($valuesTmp);
}
@@ -367,7 +364,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -406,7 +403,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return true;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -444,8 +441,8 @@ SQL;
$values = [$is_read ? 1 : 0];
$values = array_merge($values, $ids);
$stm = $this->pdo->prepare($sql);
- if (!($stm && $stm->execute($values))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute($values)) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
return false;
}
@@ -465,7 +462,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
return false;
}
@@ -514,8 +511,8 @@ SQL;
[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
- if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -555,8 +552,8 @@ SQL;
[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
- if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -597,8 +594,8 @@ SQL;
[$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
- if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info) . ' with SQL: ' . $sql . $search);
$this->pdo->rollBack();
return false;
@@ -613,7 +610,7 @@ SQL;
if (!($stm !== false &&
$stm->bindParam(':id', $id_feed, PDO::PARAM_INT) &&
$stm->execute())) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -655,8 +652,8 @@ SQL;
[$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
- if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -721,7 +718,7 @@ SQL;
if ($stm !== false && $stm->execute($params)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->cleanOldEntries($id_feed, $options);
}
@@ -1144,7 +1141,7 @@ SQL;
$search .= 'AND ' . $alias . 'id >= ? ';
$values[] = $date_min . '000000';
}
- if ($filters && count($filters->searches()) > 0) {
+ if ($filters !== null && count($filters->searches()) > 0) {
[$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filters);
$filterSearch = trim($filterSearch);
if ($filterSearch !== '') {
@@ -1252,7 +1249,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->listWhereRaw($type, $id, $state, $order, $limit, $offset, $firstId, $filters, $date_min);
}
@@ -1272,7 +1269,7 @@ SQL;
string $order = 'DESC', int $limit = 1, int $offset = 0, string $firstId = '',
?FreshRSS_BooleanSearch $filters = null, int $date_min = 0): Traversable {
$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $offset, $firstId, $filters, $date_min);
- if ($stm) {
+ if ($stm !== false) {
while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
if (is_array($row)) {
/** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,
@@ -1343,7 +1340,7 @@ SQL;
/** @var array<numeric-string> $res */
return $res;
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return null;
}
@@ -1377,7 +1374,7 @@ SQL;
}
return $result;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->listHashForFeedGuids($id_feed, $guids);
}
@@ -1413,7 +1410,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->updateLastSeen($id_feed, $guids);
}
@@ -1448,7 +1445,7 @@ SQL;
$stm->execute()) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info) . ' while updating feed ' . $id_feed);
return false;
}
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index 6d604f25a..7cf6eb202 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -52,7 +52,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
/** @param array<string|int> $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {
- if ($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) {
+ if (($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) !== false) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1) ?: [];
foreach (['attributes'] as $column) {
if (!in_array($column, $columns, true)) {
@@ -117,8 +117,8 @@ SQL;
$sql = 'UPDATE `_entry` SET is_read=? WHERE id=? AND is_read=?';
$values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1];
$stm = $this->pdo->prepare($sql);
- if (!($stm && $stm->execute($values))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute($values)) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -129,8 +129,8 @@ SQL;
. 'WHERE id=(SELECT e.id_feed FROM `_entry` e WHERE e.id=?)';
$values = [$ids];
$stm = $this->pdo->prepare($sql);
- if (!($stm && $stm->execute($values))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute($values)) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -167,8 +167,8 @@ SQL;
[$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);
$stm = $this->pdo->prepare($sql . $search);
- if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute(array_merge($values, $searchValues))) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 6e468e33f..37f1d8cd4 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -371,7 +371,7 @@ class FreshRSS_Feed extends Minz_Model {
Minz_ExtensionManager::callHook('simplepie_before_init', $simplePie, $this);
$mtime = $simplePie->init();
- if ((!$mtime) || $simplePie->error()) {
+ if ((!$mtime) || !empty($simplePie->error())) {
$errorMessage = $simplePie->error();
if (empty($errorMessage)) {
$errorMessage = '';
@@ -950,7 +950,7 @@ class FreshRSS_Feed extends Minz_Model {
public function pubSubHubbubEnabled(): bool {
$url = $this->selfUrl ?: $this->url;
$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
- if ($hubFile = @file_get_contents($hubFilename)) {
+ if (($hubFile = @file_get_contents($hubFilename)) != false) {
$hubJson = json_decode($hubFile, true);
if (is_array($hubJson) && empty($hubJson['error']) &&
(empty($hubJson['lease_end']) || $hubJson['lease_end'] > time())) {
@@ -976,10 +976,10 @@ class FreshRSS_Feed extends Minz_Model {
public function pubSubHubbubPrepare(): string|false {
$key = '';
if (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) &&
- $this->hubUrl && $this->selfUrl && @is_dir(PSHB_PATH)) {
+ $this->hubUrl !== '' && $this->selfUrl !== '' && @is_dir(PSHB_PATH)) {
$path = PSHB_PATH . '/feeds/' . sha1($this->selfUrl);
$hubFilename = $path . '/!hub.json';
- if ($hubFile = @file_get_contents($hubFilename)) {
+ if (($hubFile = @file_get_contents($hubFilename)) != false) {
$hubJson = json_decode($hubFile, true);
if (!is_array($hubJson) || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
$text = 'Invalid JSON for WebSub: ' . $this->url;
@@ -1027,7 +1027,7 @@ class FreshRSS_Feed extends Minz_Model {
} else {
$url = $this->url; //Always use current URL during unsubscribe
}
- if ($url && (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) || !$state)) {
+ if ($url !== '' && (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) || !$state)) {
$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
$hubFile = @file_get_contents($hubFilename);
if ($hubFile === false) {
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 96a8fc3c5..e6bd34185 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -71,7 +71,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
$feedId = $this->pdo->lastInsertId('`_feed_id_seq`');
return $feedId === false ? false : (int)$feedId;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->addFeed($valuesTmp);
}
@@ -83,7 +83,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
public function addFeedObject(FreshRSS_Feed $feed): int|false {
// Add feed only if we don’t find it in DB
$feed_search = $this->searchByUrl($feed->url());
- if (!$feed_search) {
+ if ($feed_search === null) {
$values = [
'id' => $feed->id(),
'url' => $feed->url(),
@@ -176,7 +176,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
if ($this->autoUpdateDb($info)) {
return $this->updateFeed($id, $originalValues);
}
@@ -212,7 +212,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
return false;
}
@@ -244,7 +244,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -259,7 +259,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -280,7 +280,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -460,7 +460,7 @@ SQL;
if ($stm !== false && $stm->execute($feedIds)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -482,14 +482,14 @@ WHERE id_feed=:id_feed1 AND is_read=0 AND id <= (SELECT e3.id FROM (
OFFSET :limit) e3)
SQL;
- if (($stm = $this->pdo->prepare($sql)) &&
+ if (($stm = $this->pdo->prepare($sql)) !== false &&
$stm->bindParam(':id_feed1', $id, PDO::PARAM_INT) &&
$stm->bindParam(':id_feed2', $id, PDO::PARAM_INT) &&
$stm->bindParam(':limit', $n, PDO::PARAM_INT) &&
$stm->execute()) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -505,13 +505,13 @@ UPDATE `_entry` SET is_read=1
WHERE id_feed=:id_feed AND is_read=0 AND (`lastSeen` + 10 < :min_last_seen)
SQL;
- if (($stm = $this->pdo->prepare($sql)) &&
+ if (($stm = $this->pdo->prepare($sql)) !== false &&
$stm->bindValue(':id_feed', $id, PDO::PARAM_INT) &&
$stm->bindValue(':min_last_seen', $minLastSeen, PDO::PARAM_INT) &&
$stm->execute()) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -524,7 +524,7 @@ SQL;
if (!($stm !== false &&
$stm->bindParam(':id', $id, PDO::PARAM_INT) &&
$stm->execute())) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -536,7 +536,7 @@ SQL;
if (!($stm !== false &&
$stm->bindParam(':id', $id, PDO::PARAM_INT) &&
$stm->execute())) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -550,8 +550,8 @@ SQL;
$sql = 'DELETE FROM `_entry`';
$stm = $this->pdo->prepare($sql);
$this->pdo->beginTransaction();
- if (!($stm && $stm->execute())) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute()) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -559,8 +559,8 @@ SQL;
$sql = 'UPDATE `_feed` SET `cache_nbEntries` = 0, `cache_nbUnreads` = 0';
$stm = $this->pdo->prepare($sql);
- if (!($stm && $stm->execute())) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ if ($stm === false || !$stm->execute()) {
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
$this->pdo->rollBack();
return false;
@@ -618,7 +618,7 @@ SQL;
public function count(): int {
$sql = 'SELECT COUNT(e.id) AS count FROM `_feed` e';
$stm = $this->pdo->query($sql);
- if ($stm == false) {
+ if ($stm === false) {
return -1;
}
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php
index 69b859b79..5833a7985 100644
--- a/app/Models/FeedDAOSQLite.php
+++ b/app/Models/FeedDAOSQLite.php
@@ -6,7 +6,7 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO {
/** @param array<int|string> $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {
- if ($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) {
+ if (($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) !== false) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
foreach (['attributes', 'kind'] as $column) {
if (!in_array($column, $columns, true)) {
diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.php
index 5bd6d97bc..54b468da9 100644
--- a/app/Models/FormAuth.php
+++ b/app/Models/FormAuth.php
@@ -32,7 +32,7 @@ class FreshRSS_FormAuth {
}
$credentials = @file_get_contents($token_file);
- if ($credentials !== false && self::renewCookie($token)) {
+ if ($credentials !== false && self::renewCookie($token) != false) {
return explode("\t", $credentials, 2);
}
return [];
diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php
index 9d271455e..3916d2a1e 100644
--- a/app/Models/LogDAO.php
+++ b/app/Models/LogDAO.php
@@ -13,7 +13,7 @@ final class FreshRSS_LogDAO {
public static function lines(?string $logFileName = null): array {
$logs = [];
$handle = @fopen(self::logPath($logFileName), 'r');
- if ($handle) {
+ if (is_resource($handle)) {
while (($line = fgets($handle)) !== false) {
if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
$myLog = new FreshRSS_Log();
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 920a09c2c..e26a73a65 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -34,7 +34,7 @@ SQL;
$tagId = $this->pdo->lastInsertId('`_tag_id_seq`');
return $tagId === false ? false : (int)$tagId;
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -42,7 +42,7 @@ SQL;
public function addTagObject(FreshRSS_Tag $tag): int|false {
$tag0 = $this->searchByName($tag->name());
- if (!$tag0) {
+ if ($tag0 === null) {
$values = [
'name' => $tag->name(),
'attributes' => $tag->attributes(),
@@ -68,7 +68,7 @@ SQL;
$stm->execute()) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -86,7 +86,7 @@ SQL;
$stm->execute()) {
return $stm->rowCount();
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -111,7 +111,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
} else {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -155,7 +155,7 @@ SQL;
$stm = $this->pdo->prepare($sql);
if ($stm === false || !$stm->execute([$newTagId, $oldTagId])) {
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));
return false;
}
@@ -166,7 +166,7 @@ SQL;
if ($stm !== false && $stm->execute([$newTagId, $oldTagId])) {
return $stm->rowCount();
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));
return false;
}
@@ -285,7 +285,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return true;
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -341,7 +341,7 @@ SQL;
}
return $lines;
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
@@ -396,7 +396,7 @@ SQL;
if ($stm !== false && $stm->execute($values)) {
return $stm->fetchAll(PDO::FETCH_ASSOC);
}
- $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
return false;
}
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index 055db42e5..a5167c8e8 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -21,7 +21,7 @@ class FreshRSS_Themes extends Minz_Model {
$list = [];
foreach ($themes_list as $theme_dir) {
$theme = self::get_infos($theme_dir);
- if ($theme) {
+ if (is_array($theme)) {
$list[$theme_dir] = $theme;
}
}
@@ -60,7 +60,7 @@ class FreshRSS_Themes extends Minz_Model {
*/
public static function load(string $theme_id): array|false {
$infos = self::get_infos($theme_id);
- if (!$infos) {
+ if (empty($infos)) {
if ($theme_id !== self::$defaultTheme) { //Fall-back to default theme
return self::load(self::$defaultTheme);
}
diff --git a/app/Models/View.php b/app/Models/View.php
index c586d8632..244379505 100644
--- a/app/Models/View.php
+++ b/app/Models/View.php
@@ -17,8 +17,8 @@ class FreshRSS_View extends Minz_View {
public string $current_user;
/** @var iterable<FreshRSS_Entry> */
public $entries;
- public FreshRSS_Entry $entry;
- public FreshRSS_Feed $feed;
+ public ?FreshRSS_Entry $entry = null;
+ public ?FreshRSS_Feed $feed = null;
/** @var array<int,FreshRSS_Feed> */
public array $feeds;
public int $nbUnreadTags;
@@ -30,7 +30,7 @@ class FreshRSS_View extends Minz_View {
public array $tagsForEntries;
public bool $excludeMutedFeeds;
- // Substriptions
+ // Subscriptions
public bool $displaySlider = false;
public bool $load_ok;
public bool $onlyFeedsWithError;
diff --git a/app/Models/ViewStats.php b/app/Models/ViewStats.php
index 608633f6b..3810312db 100644
--- a/app/Models/ViewStats.php
+++ b/app/Models/ViewStats.php
@@ -5,7 +5,7 @@ final class FreshRSS_ViewStats extends FreshRSS_View {
/** @var array<int,FreshRSS_Category> */
public array $categories;
- public FreshRSS_Feed $feed;
+ public ?FreshRSS_Feed $feed = null;
/** @var array<int,FreshRSS_Feed> */
public array $feeds;
public bool $displaySlider = false;