aboutsummaryrefslogtreecommitdiff
path: root/app
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
parent31c8846791d4b5316fbc790202f79545c012f9c2 (diff)
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions * Uniformisation
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/feedController.php14
-rw-r--r--app/Controllers/importExportController.php4
-rw-r--r--app/Controllers/subscriptionController.php2
-rw-r--r--app/Controllers/tagController.php2
-rw-r--r--app/FreshRSS.php2
-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
-rw-r--r--app/Services/ExportService.php2
-rw-r--r--app/Services/ImportService.php8
-rw-r--r--app/views/configure/archiving.phtml4
-rw-r--r--app/views/configure/queries.phtml4
-rw-r--r--app/views/configure/query.phtml2
-rw-r--r--app/views/helpers/feed/update.phtml3
-rw-r--r--app/views/helpers/index/article.phtml9
-rw-r--r--app/views/helpers/index/normal/entry_bottom.phtml3
-rw-r--r--app/views/helpers/index/normal/entry_header.phtml3
-rw-r--r--app/views/helpers/index/tags.phtml3
-rw-r--r--app/views/helpers/stream-footer.phtml2
-rw-r--r--app/views/index/normal.phtml11
-rw-r--r--app/views/stats/repartition.phtml4
-rw-r--r--app/views/subscription/feed.phtml2
35 files changed, 183 insertions, 162 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 42639f5e1..3f4ed3149 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -92,7 +92,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
$feedDAO = FreshRSS_Factory::createFeedDao();
- if ($feedDAO->searchByUrl($feed->url())) {
+ if ($feedDAO->searchByUrl($feed->url()) !== null) {
throw new FreshRSS_AlreadySubscribed_Exception($url, $feed->name());
}
@@ -340,7 +340,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
$feed = $feedDAO->searchByUrl($this->view->feed->url());
- if ($feed) {
+ if ($feed !== null) {
// Already subscribe so we redirect to the feed configuration page.
$url_redirect['a'] = 'feed';
$url_redirect['params']['id'] = $feed->id();
@@ -617,7 +617,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$needFeedCacheRefresh = true;
- if ($pubSubHubbubEnabled && !$simplePiePush) { //We use push, but have discovered an article by pull!
+ if ($pubSubHubbubEnabled && $simplePiePush === null) { //We use push, but have discovered an article by pull!
$text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' .
SimplePie_Misc::url_remove_credentials($url) .
' GUID ' . $entry->guid();
@@ -658,10 +658,10 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$feedProperties = [];
- if ($pubsubhubbubEnabledGeneral && $feed->hubUrl() && $feed->selfUrl()) { //selfUrl has priority for WebSub
+ if ($pubsubhubbubEnabledGeneral && $feed->hubUrl() !== '' && $feed->selfUrl() !== '') { //selfUrl has priority for WebSub
if ($feed->selfUrl() !== $url) { // https://github.com/pubsubhubbub/PubSubHubbub/wiki/Moving-Feeds-or-changing-Hubs
$selfUrl = checkUrl($feed->selfUrl());
- if ($selfUrl) {
+ if ($selfUrl != false) {
Minz_Log::debug('WebSub unsubscribe ' . $feed->url(false));
if (!$feed->pubSubHubbubSubscribe(false)) { //Unsubscribe
Minz_Log::warning('Error while WebSub unsubscribing from ' . $feed->url(false));
@@ -709,7 +709,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
$feed->faviconPrepare();
- if ($pubsubhubbubEnabledGeneral && $feed->pubSubHubbubPrepare()) {
+ if ($pubsubhubbubEnabledGeneral && $feed->pubSubHubbubPrepare() != false) {
Minz_Log::notice('WebSub subscribe ' . $feed->url(false));
if (!$feed->pubSubHubbubSubscribe(true)) { //Subscribe
Minz_Log::warning('Error while WebSub subscribing to ' . $feed->url(false));
@@ -997,7 +997,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
break;
case 'normal':
$get = Minz_Request::paramString('get');
- if ($get) {
+ if ($get !== '') {
$redirect_url = ['c' => 'index', 'a' => 'normal', 'params' => ['get' => $get]];
} else {
$redirect_url = ['c' => 'index', 'a' => 'normal'];
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 62f7721ab..50c2037fe 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -351,7 +351,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
}
}
- if ($feed != null) {
+ if ($feed !== null) {
$article_to_feed[$item['guid']] = $feed->id();
if (!isset($newFeedGuids['f_' . $feed->id()])) {
$newFeedGuids['f_' . $feed->id()] = [];
@@ -627,7 +627,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
foreach ($export_feeds as $feed_id) {
$result = $export_service->generateFeedEntries((int)$feed_id, $max_number_entries);
- if (!$result) {
+ if ($result === null) {
// It means the actual feed_id doesn’t correspond to any existing feed
continue;
}
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index af18bbced..fe228829a 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -304,7 +304,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
case 'normal':
case 'reader':
$get = Minz_Request::paramString('get');
- if ($get) {
+ if ($get !== '') {
$url_redirect = ['c' => 'index', 'a' => $from, 'params' => ['get' => $get]];
} else {
$url_redirect = ['c' => 'index', 'a' => $from];
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index 02bb930ee..2bc7c0e1f 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -40,7 +40,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
if ($id_entry != '') {
$tagDAO = FreshRSS_Factory::createTagDao();
if ($id_tag == 0 && $name_tag !== '' && $checked) {
- if ($existing_tag = $tagDAO->searchByName($name_tag)) {
+ if (($existing_tag = $tagDAO->searchByName($name_tag)) !== null) {
// Use existing tag
$tagDAO->tagEntry($existing_tag->id(), $id_entry, $checked);
} else {
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index ff766ad47..06557dbe1 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -111,7 +111,7 @@ class FreshRSS extends Minz_FrontController {
return;
}
$theme = FreshRSS_Themes::load(FreshRSS_Context::userConf()->theme);
- if ($theme) {
+ if (is_array($theme)) {
foreach (array_reverse($theme['files']) as $file) {
switch (substr($file, -3)) {
case '.js':
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;
diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php
index ba4042d21..37bcdc6e3 100644
--- a/app/Services/ExportService.php
+++ b/app/Services/ExportService.php
@@ -130,7 +130,7 @@ class FreshRSS_Export_Service {
$exported_files = [];
foreach ($feed_ids as $feed_id) {
$result = $this->generateFeedEntries($feed_id, $max_number_entries);
- if (!$result) {
+ if ($result === null) {
continue;
}
diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php
index 8060e4d51..9ec36b61c 100644
--- a/app/Services/ImportService.php
+++ b/app/Services/ImportService.php
@@ -91,7 +91,7 @@ class FreshRSS_Import_Service {
if ($can_create_category) {
$category = $this->createCategory($category_element, $dry_run);
- if ($category) {
+ if ($category !== null) {
$categories_by_names[$category->name()] = $category;
$nb_categories++;
}
@@ -102,7 +102,7 @@ class FreshRSS_Import_Service {
}
}
- if (!$category) {
+ if ($category === null) {
// Category can be null if the feeds weren't in a category
// outline, or if we weren't able to create the category.
$category = $default_category;
@@ -121,7 +121,7 @@ class FreshRSS_Import_Service {
break;
}
- if ($this->createFeed($feed_element, $category, $dry_run)) {
+ if ($this->createFeed($feed_element, $category, $dry_run) !== null) {
// TODO what if the feed already exists in the database?
$nb_feeds++;
} else {
@@ -301,7 +301,7 @@ class FreshRSS_Import_Service {
return $feed;
}
- if ($feed != null) {
+ if ($feed !== null) {
// addFeedObject checks if feed is already in DB
$id = $this->feedDAO->addFeedObject($feed);
if ($id == false) {
diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml
index 86b8246e3..7ab8a2d9a 100644
--- a/app/views/configure/archiving.phtml
+++ b/app/views/configure/archiving.phtml
@@ -59,8 +59,8 @@
<div class="group-controls">
<label class="checkbox" for="enable_keep_period">
<input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?=
- FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? ' checked="checked"' : '' ?>
- data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? 1 : 0 ?>"/>
+ empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? '' : ' checked="checked"' ?>
+ data-leave-validation="<?= empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? 0 : 1 ?>"/>
<?= _t('conf.archiving.keep_period') ?>
<input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"
data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"/>
diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml
index 26534307e..d085016fb 100644
--- a/app/views/configure/queries.phtml
+++ b/app/views/configure/queries.phtml
@@ -49,11 +49,11 @@
<li class="item"><?= _t('conf.query.state_' . $query->getState()) ?></li>
<?php } ?>
- <?php if ($query->getOrder()) { ?>
+ <?php if ($query->getOrder() !== '') { ?>
<li class="item"><?= _t('conf.query.order_' . strtolower($query->getOrder())) ?></li>
<?php } ?>
- <?php if ($query->getGet()) { ?>
+ <?php if ($query->getGet() !== '') { ?>
<li class="item"><?= _t('conf.query.get_' . $query->getGetType(), $query->getGetName()) ?></li>
<?php } ?>
<?php } ?>
diff --git a/app/views/configure/query.phtml b/app/views/configure/query.phtml
index e45820fbc..51051b98a 100644
--- a/app/views/configure/query.phtml
+++ b/app/views/configure/query.phtml
@@ -5,6 +5,6 @@ declare(strict_types=1);
if (!Minz_Request::paramBoolean('ajax')) {
$this->partial('aside_configure');
}
-if ($this->query) {
+if ($this->query !== null) {
$this->renderHelper('configure/query');
}
diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml
index 93a528532..7f0be0f0c 100644
--- a/app/views/helpers/feed/update.phtml
+++ b/app/views/helpers/feed/update.phtml
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
/** @var FreshRSS_View $this */
+ if ($this->feed === null) {
+ return;
+ }
?>
<div class="post" id="feed_update">
<h1><?= $this->feed->name() ?></h1>
diff --git a/app/views/helpers/index/article.phtml b/app/views/helpers/index/article.phtml
index bdc108f1e..0a9c75bcd 100644
--- a/app/views/helpers/index/article.phtml
+++ b/app/views/helpers/index/article.phtml
@@ -4,6 +4,9 @@
/** @var FreshRSS_View $this */
$entry = $this->entry;
$feed = $this->feed;
+ if ($feed === null || $entry === null) {
+ return;
+ }
?>
<article class="flux_content" dir="auto">
<div class="content <?= FreshRSS_Context::userConf()->content_width ?>">
@@ -29,7 +32,7 @@
<div class="item manage">
<a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($entry->isFavorite() ? 'starred' : 'non-starred') ?></a>
</div>
- <?php } ?>
+ <?php } ?>
<?php } ?>
<div class="item">
<?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
@@ -42,7 +45,7 @@
<?php
if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 't') { ?>
<div class="item link">
- <a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
+ <a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
</div>
<?php } ?>
</div>
@@ -93,7 +96,7 @@
<?php
if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 'a') { ?>
<div class="item link">
- <a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
+ <a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a>
</div>
<?php } ?>
</div>
diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml
index 1de8395bc..51c103a74 100644
--- a/app/views/helpers/index/normal/entry_bottom.phtml
+++ b/app/views/helpers/index/normal/entry_bottom.phtml
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
/** @var FreshRSS_View $this */
+ if ($this->entry === null) {
+ return;
+ }
$bottomline_read = FreshRSS_Context::userConf()->bottomline_read;
$bottomline_favorite = FreshRSS_Context::userConf()->bottomline_favorite;
$bottomline_sharing = FreshRSS_Context::userConf()->bottomline_sharing && (count(FreshRSS_Context::userConf()->sharing) > 0);
diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml
index ecaf0f0d6..a2f8d00fc 100644
--- a/app/views/helpers/index/normal/entry_header.phtml
+++ b/app/views/helpers/index/normal/entry_header.phtml
@@ -11,6 +11,9 @@
$topline_date = FreshRSS_Context::userConf()->topline_date;
$topline_link = FreshRSS_Context::userConf()->topline_link;
$lazyload = FreshRSS_Context::userConf()->lazyload;
+ if ($this->feed === null || $this->entry === null) {
+ return;
+ }
?><ul class="horizontal-list flux_header website<?= $topline_website ?>" data-website-name="<?= $this->feed->name() ?>" data-article-authors="<?= implode(', ', $this->entry->authors()) ?>"><?php
if (FreshRSS_Auth::hasAccess()) {
if ($topline_read) {
diff --git a/app/views/helpers/index/tags.phtml b/app/views/helpers/index/tags.phtml
index 8f67784dd..3308bd7e9 100644
--- a/app/views/helpers/index/tags.phtml
+++ b/app/views/helpers/index/tags.phtml
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
/** @var FreshRSS_View $this */
+ if ($this->entry === null) {
+ return;
+ }
[$firstTags,$remainingTags] = $this->entry->tagsFormattingHelper();
?>
<div class="tags">
diff --git a/app/views/helpers/stream-footer.phtml b/app/views/helpers/stream-footer.phtml
index 9681cff02..bd6a8a880 100644
--- a/app/views/helpers/stream-footer.phtml
+++ b/app/views/helpers/stream-footer.phtml
@@ -27,7 +27,7 @@
<div id="stream-footer">
<?php }?>
<div class="stream-footer-inner">
- <?php if (FreshRSS_Context::$next_id) { ?>
+ <?php if (FreshRSS_Context::$next_id !== '') { ?>
<button id="load_more" type="submit" class="btn" formaction="<?= Minz_Url::display($url_next) ?>"><?= _t('gen.stream.load_more') ?></button>
<?php } elseif ($hasAccess) { ?>
<?= _t('gen.stream.nothing_to_load') ?><br />
diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml
index 40adc7f16..fe4af1a86 100644
--- a/app/views/index/normal.phtml
+++ b/app/views/index/normal.phtml
@@ -74,6 +74,9 @@ $today = @strtotime('today');
?>" data-priority="<?= $this->feed->priority()
?>"><?php
$this->renderHelper('index/normal/entry_header');
+ if ($this->feed === null || $this->entry === null) {
+ throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
+ }
?><article class="flux_content" dir="auto">
<div class="content <?= FreshRSS_Context::userConf()->content_width ?>">
<header>
@@ -86,6 +89,9 @@ $today = @strtotime('today');
<?php } ?>
<?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
$this->renderHelper('index/tags');
+ if ($this->feed === null || $this->entry === null) {
+ throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan
+ }
} ?>
<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1>
<?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
@@ -196,4 +202,7 @@ $today = @strtotime('today');
<?= _i('close') ?>
</a>
-<?php if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?>
+<?php
+ if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) {
+ $this->partial('nav_entries');
+ }
diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml
index 030db0906..dd4ff9b29 100644
--- a/app/views/stats/repartition.phtml
+++ b/app/views/stats/repartition.phtml
@@ -17,7 +17,7 @@
if (!empty($feeds)) {
echo '<optgroup label="', $category->name(), '">';
foreach ($feeds as $feed) {
- if ($this->feed && $feed->id() == $this->feed->id()) {
+ if ($this->feed !== null && $feed->id() == $this->feed->id()) {
echo '<option value="', $feed->id(), '" selected="selected" data-url="',
_url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>';
} else {
@@ -30,7 +30,7 @@
}?>
</select>
- <?php if ($this->feed) {?>
+ <?php if ($this->feed !== null) {?>
<a class="btn" href="<?= _url('subscription', 'feed', 'id', $this->feed->id()) ?>">
<?= _i('configure') ?> <?= _t('gen.action.manage') ?>
</a>
diff --git a/app/views/subscription/feed.phtml b/app/views/subscription/feed.phtml
index 934e3c690..cbe91cd4d 100644
--- a/app/views/subscription/feed.phtml
+++ b/app/views/subscription/feed.phtml
@@ -6,7 +6,7 @@ if (!Minz_Request::paramBoolean('ajax')) {
$this->partial('aside_subscription');
}
-if ($this->feed) {
+if ($this->feed !== null) {
$this->renderHelper('feed/update');
} else {
?>