summaryrefslogtreecommitdiffstats
path: root/businesslayer
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-08-28 19:19:28 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-08-28 19:19:28 +0200
commit2f67340e551b12dce8824381c3291bb2137857cb (patch)
tree2342cb35b5b337e083bb2fdc866a3d10d92f99c7 /businesslayer
parenta9eb72911b6f022da645dc08cf8c0f4b1702d1e1 (diff)
Possible backwards incompatible change by using the link provided by simplepie instead of the user for the url hash. This prevents duplication of the feed when adding a slightly different feed url which points to the same feed and allows a speedup from O(n) to O(1) for article enhanchers
Diffstat (limited to 'businesslayer')
-rw-r--r--businesslayer/feedbusinesslayer.php18
1 files changed, 10 insertions, 8 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php
index 764cb07c6..cf79d0b22 100644
--- a/businesslayer/feedbusinesslayer.php
+++ b/businesslayer/feedbusinesslayer.php
@@ -95,14 +95,15 @@ class FeedBusinessLayer extends BusinessLayer {
public function create($feedUrl, $folderId, $userId){
// first try if the feed exists already
try {
- $this->mapper->findByUrlHash(md5($feedUrl), $userId);
- throw new BusinessLayerExistsException(
- $this->api->getTrans()->t('Can not add feed: Exists already'));
- } catch(DoesNotExistException $ex){}
-
- try {
list($feed, $items) = $this->feedFetcher->fetch($feedUrl);
+ // try again if feed exists depending on the reported link
+ try {
+ $this->mapper->findByUrlHash($feed->getUrlHash(), $userId);
+ throw new BusinessLayerExistsException(
+ $this->api->getTrans()->t('Can not add feed: Exists already'));
+ } catch(DoesNotExistException $ex){}
+
// insert feed
$feed->setFolderId($folderId);
$feed->setUserId($userId);
@@ -123,7 +124,7 @@ class FeedBusinessLayer extends BusinessLayer {
continue;
} catch(DoesNotExistException $ex){
$unreadCount += 1;
- $item = $this->enhancer->enhance($item);
+ $item = $this->enhancer->enhance($item, $feed->getLink());
$this->itemMapper->insert($item);
}
}
@@ -189,7 +190,8 @@ class FeedBusinessLayer extends BusinessLayer {
try {
$this->itemMapper->findByGuidHash($item->getGuidHash(), $feedId, $userId);
} catch(DoesNotExistException $ex){
- $item = $this->enhancer->enhance($item);
+ $item = $this->enhancer->enhance($item,
+ $existingFeed->getLink());
$this->itemMapper->insert($item);
}
}