From 1fcab6e6c6bd5dd496fbeda41dabb668e17e9ada Mon Sep 17 00:00:00 2001 From: anoy Date: Fri, 9 Oct 2020 19:08:30 +0200 Subject: fix multiple results for guid_hash Signed-off-by: anoy --- lib/Db/ItemMapperV2.php | 5 ++++- lib/Service/ItemServiceV2.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php index 54d9ecbaf..8bd939e71 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -99,6 +99,7 @@ class ItemMapperV2 extends NewsMapperV2 /** * Find an item by a GUID hash. * + * @param int $feedId ID of the feed * @param string $guidHash hash to find with * * @return Item|Entity @@ -106,12 +107,14 @@ class ItemMapperV2 extends NewsMapperV2 * @throws DoesNotExistException * @throws MultipleObjectsReturnedException */ - public function findByGuidHash(string $guidHash): Item + public function findByGuidHash(int $feedId, string $guidHash): Item { $builder = $this->db->getQueryBuilder(); $builder->addSelect('*') ->from($this->tableName) + ->andWhere('feed_id = :feed_id') ->andWhere('guid_hash = :guid_hash') + ->setParameter(':feed_id', $feedId, IQueryBuilder::PARAM_INT) ->setParameter(':guid_hash', $guidHash, IQueryBuilder::PARAM_STR); return $this->findEntity($builder); diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index c88a7293a..b4cb16e22 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -75,7 +75,7 @@ class ItemServiceV2 extends Service public function insertOrUpdate(Item $item) { try { - $db_item = $this->mapper->findByGuidHash($item->getGuidHash()); + $db_item = $this->mapper->findByGuidHash($item->getFeedId(), $item->getGuidHash()); // Transfer user modifications $item->setUnread($db_item->isUnread()) -- cgit v1.2.3