aboutsummaryrefslogtreecommitdiff
path: root/app/Models/FeedDAO.php
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/FeedDAO.php
parent31c8846791d4b5316fbc790202f79545c012f9c2 (diff)
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions * Uniformisation
Diffstat (limited to 'app/Models/FeedDAO.php')
-rw-r--r--app/Models/FeedDAO.php38
1 files changed, 19 insertions, 19 deletions
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);