diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-02 12:04:45 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-02 12:04:45 +0200 |
commit | c795c0aa10f7d404a96ac893d3ba2972724d8511 (patch) | |
tree | 56b8a9bc27379ac0fb28d21abd831acf8eaef13f /bl | |
parent | bd7d13ce963f286459684934257a6a1e61d7bfc7 (diff) |
fix #11 by not relying on db exceptions anymore since there is no fking proper exception handling in the owncloud db code and stuff will break. instead update when item has been found and if not insert
Diffstat (limited to 'bl')
-rw-r--r-- | bl/feedbl.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php index 0bd0e9e0d..661f1f8f5 100644 --- a/bl/feedbl.php +++ b/bl/feedbl.php @@ -111,33 +111,32 @@ class FeedBl extends Bl { // newest item for($i=count($items)-1; $i>=0; $i--){ $item = $items[$i]; + $item->setFeedId($feed->getId()); - // if a database exception is being thrown the unique constraint - // on the item guid hash is being violated and we need to update - // the item + // if a doesnotexist exception is being thrown the entry does not + // exist and the item needs to be created, otherwise + // update it try { - $item->setFeedId($feed->getId()); - $this->itemMapper->insert($item); - } catch(\DatabaseException $ex){ + $existing = $this->itemMapper->findByGuidHash( + $item->getGuidHash(), $feedId, $userId); // in case of an update the existing item has to be deleted // if the pub_date changed because we sort by id on the // client side since this is the only reliable way to do it // to not get weird behaviour - $existing = $this->itemMapper->findByGuidHash( - $item->getGuidHash(), $feedId, $userId); - if($existing->getPubDate() !== $item->getPubDate()){ // because the item is being replaced we need to keep - // status flags + // status flags but we want the new entry to be unread $item->setStatus($existing->getStatus()); $item->setUnread(); $this->itemMapper->delete($existing); $this->itemMapper->insert($item); } - + + } catch(DoesNotExistException $ex){ + $this->itemMapper->insert($item); } } |