A free, self-hostable news aggregator…
Fix last update & archive logic (#4422)
Alexandre Alapetite07a52137a975
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 49383342e..dd87650bc 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -361,6 +361,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {}//Minz_Log::debug($feed->url(false) . ' was updated at ' . date('c', $mtime) . ' by another user');//Will take advantage of the newer cache+ } else {+ $mtime = time();}if (!$feed->lock()) {@@ -413,9 +415,9 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {// For this feed, check existing GUIDs already in database.$existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids);- $newGuids = array();+ /** @var array<string,bool> */+ $newGuids = [];- $oldGuids = array();// Add entries in database if possible./** @var FreshRSS_Entry $entry */foreach ($entries as $entry) {@@ -426,10 +428,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {if (isset($existingHashForGuids[$entry->guid()])) {$existingHash = $existingHashForGuids[$entry->guid()];- if (strcasecmp($existingHash, $entry->hash()) === 0) {- //This entry already exists and is unchanged.- $oldGuids[] = $entry->guid();- } else { //This entry already exists but has been updated+ if (strcasecmp($existingHash, $entry->hash()) !== 0) {+ //This entry already exists but has been updated//Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url(false) .//', old hash ' . $existingHash . ', new hash ' . $entry->hash());$entry->_isRead($mark_updated_article_unread ? false : null); //Change is_read according to policy.@@ -488,7 +488,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$nb_new_articles++;}}- $entryDAO->updateLastSeen($feed->id(), $oldGuids, $mtime);+ $entryDAO->updateLastSeen($feed->id(), array_keys($newGuids), $mtime);}unset($entries);diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex 426c294c4..d87f3b7c4 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -1170,6 +1170,12 @@ SQL;}}+ /**+ * @param int $id_feed+ * @param array<string> $guids+ * @param int $mtime+ * @return int|false The number of affected feeds, or false if error+ */public function updateLastSeen($id_feed, $guids, $mtime = 0) {if (count($guids) < 1) {return 0;