From ea503975d5967dd9605f8e8df8a77fc1e5bc2e3a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 16 May 2023 12:09:39 +0200 Subject: Fix again updateLastSeenUnchanged (#5404) * Fix again updateLastSeenUnchanged https://github.com/FreshRSS/FreshRSS/pull/5382 was not good enough to fix markAsReadUponGone and introduced a regression in `entry.lastSeen`. New approach. Follow-up of https://github.com/FreshRSS/FreshRSS/pull/5315 * Minor change of mind * Fix handling of lastSeen entry.lastSeen was not always correctly initialised, and sometimes overriden --- app/Models/EntryDAO.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 50bd0584c..80101ca24 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -221,7 +221,7 @@ SQL; /** @var PDOStatement|null */ private $updateEntryPrepared = null; - /** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'hash':string, + /** @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} $valuesTmp */ public function updateEntry(array $valuesTmp): bool { if (!isset($valuesTmp['is_read'])) { @@ -260,7 +260,6 @@ SQL; $this->updateEntryPrepared->bindParam(':link', $valuesTmp['link']); $valuesTmp['date'] = min($valuesTmp['date'], 2147483647); $this->updateEntryPrepared->bindParam(':date', $valuesTmp['date'], PDO::PARAM_INT); - $valuesTmp['lastSeen'] = time(); $this->updateEntryPrepared->bindParam(':last_seen', $valuesTmp['lastSeen'], PDO::PARAM_INT); if ($valuesTmp['is_read'] === null) { $this->updateEntryPrepared->bindValue(':is_read', null, PDO::PARAM_NULL); @@ -1277,6 +1276,7 @@ SQL; * @return int|false The number of affected entries, or false if error */ public function updateLastSeen(int $id_feed, array $guids, int $mtime = 0) { + syslog(LOG_DEBUG, __METHOD__ . ' ' . count($guids) . ' ' . $mtime); if (count($guids) < 1) { return 0; } elseif (count($guids) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) { @@ -1311,14 +1311,16 @@ SQL; /** * Update (touch) the last seen attribute of the latest entries of a given feed. * Useful when a feed is unchanged / cached. + * To be performed just before {@see FreshRSS_FeedDAO::updateLastUpdate()} * @return int|false The number of affected entries, or false in case of error */ public function updateLastSeenUnchanged(int $id_feed, int $mtime = 0) { - $sql = <<pdo->prepare($sql); -- cgit v1.2.3