summaryrefslogtreecommitdiffstats
path: root/service
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-10-27 14:36:00 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-10-27 14:36:00 +0100
commit7b058820f5cd34666b389de28afe3a11f451f742 (patch)
treeccf3ff784cd6a9a20940395df4400a45b3de2f65 /service
parenta772db735eacdf2508b8608c2e3fd00447039c9a (diff)
only update unread per article count if its bigger than the current one
Diffstat (limited to 'service')
-rw-r--r--service/feedservice.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/service/feedservice.php b/service/feedservice.php
index 6ecf543b1..4ee7cb92d 100644
--- a/service/feedservice.php
+++ b/service/feedservice.php
@@ -109,9 +109,10 @@ class FeedService extends Service {
} catch(DoesNotExistException $ex){}
// insert feed
+ $itemCount = count($items);
$feed->setFolderId($folderId);
$feed->setUserId($userId);
- $feed->setArticlesPerUpdate(count($items));
+ $feed->setArticlesPerUpdate($itemCount);
if ($title) {
$feed->setTitle($title);
@@ -122,7 +123,7 @@ class FeedService extends Service {
// insert items in reverse order because the first one is usually
// the newest item
$unreadCount = 0;
- for($i=count($items)-1; $i>=0; $i--){
+ for($i=$itemCount-1; $i>=0; $i--){
$item = $items[$i];
$item->setFeedId($feed->getId());
@@ -205,16 +206,24 @@ class FeedService extends Service {
}
// update number of articles on every feed update
- if($existingFeed->getArticlesPerUpdate() !== count($items)) {
- $existingFeed->setArticlesPerUpdate(count($items));
+ $itemCount = count($items);
+
+ // this is needed to adjust to updates that add more items
+ // than when the feed was created. You can't update the count
+ // if it's lower because it may be due to the caching headers
+ // that were sent as the request and it might cause unwanted
+ // deletion and reappearing of feeds
+ if ($itemCount > $existingFeed->getArticlesPerUpdate()) {
+ $existingFeed->setArticlesPerUpdate($itemCount);
}
+
$existingFeed->setLastModified($fetchedFeed->getLastModified());
$existingFeed->setEtag($fetchedFeed->getEtag());
$this->feedMapper->update($existingFeed);
// insert items in reverse order because the first one is
// usually the newest item
- for($i=count($items)-1; $i>=0; $i--){
+ for($i=$itemCount-1; $i>=0; $i--){
$item = $items[$i];
$item->setFeedId($existingFeed->getId());