From 8abe53d879ef188a5c1cc394894ce211fcfa9f92 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 20 Apr 2023 21:46:25 +0200 Subject: Improve markAsReadUponGone (#5315) * Improve markAsReadUponGone Fix case when the uptream feed has zero article, then old articles would never be automatically marked as read with the "mark as read when gone" policy, which was only based on the timestamp of new articles from the uptream feed. * Fix typo * Simplify request Needs to be re-tested with SQLite + MySQL * While waiting to check syntax on all database types * Fix multiple errors In the case of WebSub, and in the case of invalid GUIDs --- app/Models/Feed.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index e96323d04..a877786b4 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -278,7 +278,7 @@ class FreshRSS_Feed extends Minz_Model { if ($validate) { $url = checkUrl($url); } - if ($url == '') { + if ($url == false) { throw new FreshRSS_BadUrl_Exception($value); } $this->url = $url; @@ -306,7 +306,7 @@ class FreshRSS_Feed extends Minz_Model { if ($validate) { $value = checkUrl($value); } - if ($value == '') { + if ($value == false) { $value = ''; } $this->website = $value; @@ -448,7 +448,8 @@ class FreshRSS_Feed extends Minz_Model { $hasUniqueGuids = true; $testGuids = []; $guids = []; - $hasBadGuids = $this->attributes('hasBadGuids'); + $links = []; + $hadBadGuids = $this->attributes('hasBadGuids'); $items = $simplePie->get_items(); if (empty($items)) { @@ -463,19 +464,20 @@ class FreshRSS_Feed extends Minz_Model { $hasUniqueGuids &= empty($testGuids['_' . $guid]); $testGuids['_' . $guid] = true; $guids[] = $guid; + $links[] = $item->get_permalink(); } - if ($hasBadGuids != !$hasUniqueGuids) { - $hasBadGuids = !$hasUniqueGuids; - if ($hasBadGuids) { + if ($hadBadGuids != !$hasUniqueGuids) { + if ($hadBadGuids) { Minz_Log::warning('Feed has invalid GUIDs: ' . $this->url); } else { Minz_Log::warning('Feed has valid GUIDs again: ' . $this->url); } $feedDAO = FreshRSS_Factory::createFeedDao(); - $feedDAO->updateFeedAttribute($this, 'hasBadGuids', $hasBadGuids); + $feedDAO->updateFeedAttribute($this, 'hasBadGuids', !$hasUniqueGuids); } - return $guids; + + return $hasUniqueGuids ? $guids : $links; } /** @return iterable */ -- cgit v1.2.3