Skip to content

[Bug] The entries' "lastSeen" value might not be correct. #8643

@pe1uca

Description

@pe1uca

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.

} 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.

} 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.

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

  1. Add a feed.
  2. The feed throws an error when tried to be fetched (for example a 500 or a 429).
  3. The next fetch succeeds with no new entries.
  4. 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

Metadata

Metadata

Assignees

Labels

Bug (unconfirmed)issues that could not be reproduced yet

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions