-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Bug] The entries' "lastSeen" value might not be correct. #8643
Description
Describe the bug
This is caused by the entry's lastSeen and feed's lastUpdate going out of sync.
The function FreshRSS_EntryDAO::updateLastSeenUnchanged() is only used in this section below. It assumes the _entry.lastSeen and _feed.lastUpdate are always in sync.
FreshRSS/app/Controllers/feedController.php
Lines 703 to 716 in 71c26f5
| } elseif ($feedIsUnchanged) { | |
| // Feed cache was unchanged, so mark as seen the same entries as last time | |
| $entryDAO->updateLastSeenUnchanged($feed->id(), $mtime); | |
| } | |
| unset($entries); | |
| if (rand(0, 30) === 1) { // Remove old entries once in 30. | |
| $nb = $feed->cleanOldEntries(); | |
| if ($nb > 0) { | |
| $needFeedCacheRefresh = true; | |
| } | |
| } | |
| $feedDAO->updateLastUpdate($feed->id(), false, $mtime); |
However, the function FreshRSS_FeedDAO::updateLastUpdate() besides the above flow, is also called here, which skips updating the most recent entries.
FreshRSS/app/Controllers/feedController.php
Lines 561 to 571 in 71c26f5
| } catch (FreshRSS_Feed_Exception $e) { | |
| Minz_Log::warning($e->getMessage()); | |
| $feedDAO->updateLastUpdate($feed->id(), true); | |
| if ($e->getCode() === 410) { | |
| // HTTP 410 Gone | |
| Minz_Log::warning('Muting gone feed: ' . $feed->url(false)); | |
| $feedDAO->mute($feed->id(), true); | |
| } | |
| $feed->unlock(); | |
| continue; | |
| } |
The next time the feed is updated with no new entries, the "lastSeen" value won't be updated due to how the query is written, seen below.
FreshRSS/app/Models/EntryDAO.php
Lines 1951 to 1958 in 71c26f5
| public function updateLastSeenUnchanged(int $id_feed, int $mtime = 0): int|false { | |
| $sql = <<<'SQL' | |
| UPDATE `_entry` SET `lastSeen` = :mtime | |
| WHERE id_feed = :id_feed1 AND `lastSeen` = ( | |
| SELECT `lastUpdate` FROM `_feed` f | |
| WHERE f.id = :id_feed2 | |
| ) | |
| SQL; |
To Reproduce
- Add a feed.
- The feed throws an error when tried to be fetched (for example a 500 or a 429).
- The next fetch succeeds with no new entries.
- See in the DB "lastUpdate" and "lastSeen" are no longer the same value.
Expected behavior
"_entry.lastSeen" to always have the time when it was last returned in the feed.
FreshRSS version
1.28.2-dev
System information
- Installation type: Docker compose, from edge branch.
Additional context
No response