aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-07-30 12:01:59 +0200
committerGravatar GitHub <noreply@github.com> 2024-07-30 12:01:59 +0200
commit5659b37948c17e5e68971a2464930bee3455dfa1 (patch)
tree73cf14f73db93705489f9172f5241dececcc9c49 /app/Models
parent5c8369ce38c67fba7dd39d68626534c7e61eb24c (diff)
Fix markAsReadUponGone regression (#6663)
Regression from https://github.com/FreshRSS/FreshRSS/pull/5470 Was not working anymore when the feed was empty. Plus simplification of the logic when the feed is not empty
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/Feed.php10
-rw-r--r--app/Models/FeedDAO.php13
2 files changed, 9 insertions, 14 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index e9d031a82..731f82d14 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -843,7 +843,7 @@ class FreshRSS_Feed extends Minz_Model {
* Remember to call `updateCachedValues($id_feed)` or `updateCachedValues()` just after.
* @return int|false the number of lines affected, or false if not applicable
*/
- public function markAsReadUponGone(bool $upstreamIsEmpty, int $maxTimestamp = 0) {
+ public function markAsReadUponGone(bool $upstreamIsEmpty, int $minLastSeen = 0) {
$readUponGone = $this->attributeBoolean('read_upon_gone');
if ($readUponGone === null) {
$readUponGone = FreshRSS_Context::userConf()->mark_when['gone'];
@@ -852,14 +852,14 @@ class FreshRSS_Feed extends Minz_Model {
return false;
}
if ($upstreamIsEmpty) {
- if ($maxTimestamp <= 0) {
- $maxTimestamp = time();
+ if ($minLastSeen <= 0) {
+ $minLastSeen = time();
}
$entryDAO = FreshRSS_Factory::createEntryDao();
- $affected = $entryDAO->markReadFeed($this->id(), $maxTimestamp . '000000');
+ $affected = $entryDAO->markReadFeed($this->id(), $minLastSeen . '000000');
} else {
$feedDAO = FreshRSS_Factory::createFeedDao();
- $affected = $feedDAO->markAsReadUponGone($this->id());
+ $affected = $feedDAO->markAsReadNotSeen($this->id(), $minLastSeen);
}
if ($affected > 0) {
Minz_Log::debug(__METHOD__ . " $affected items" . ($upstreamIsEmpty ? ' (all)' : '') . ' [' . $this->url(false) . ']');
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 4a75e3dea..204f95939 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -509,20 +509,15 @@ SQL;
* Remember to call updateCachedValues() after calling this function
* @return int|false number of lines affected or false in case of error
*/
- public function markAsReadUponGone(int $id) {
- //Double SELECT for MySQL workaround ERROR 1093 (HY000)
+ public function markAsReadNotSeen(int $id, int $minLastSeen) {
$sql = <<<'SQL'
UPDATE `_entry` SET is_read=1
-WHERE id_feed=:id_feed1 AND is_read=0 AND (
- `lastSeen` + 60 < (SELECT s1.maxlastseen FROM (
- SELECT MAX(e2.`lastSeen`) AS maxlastseen FROM `_entry` e2 WHERE e2.id_feed = :id_feed2
- ) s1)
-)
+WHERE id_feed=:id_feed AND is_read=0 AND (`lastSeen` + 10 < :min_last_seen)
SQL;
if (($stm = $this->pdo->prepare($sql)) &&
- $stm->bindParam(':id_feed1', $id, PDO::PARAM_INT) &&
- $stm->bindParam(':id_feed2', $id, PDO::PARAM_INT) &&
+ $stm->bindValue(':id_feed', $id, PDO::PARAM_INT) &&
+ $stm->bindValue(':min_last_seen', $minLastSeen, PDO::PARAM_INT) &&
$stm->execute()) {
return $stm->rowCount();
} else {