summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranoy <anoymouserver+github@mailbox.org>2020-10-09 19:08:30 +0200
committerSean Molenaar <SMillerDev@users.noreply.github.com>2020-10-09 20:38:58 +0200
commit1fcab6e6c6bd5dd496fbeda41dabb668e17e9ada (patch)
tree1335fa5a62c038585ccd624bec53eacbe8c0fd7a
parenta74491ecdefb022c3cd9712ae46bff7a71c8eade (diff)
fix multiple results for guid_hash
Signed-off-by: anoy <anoymouserver+github@mailbox.org>
-rw-r--r--lib/Db/ItemMapperV2.php5
-rw-r--r--lib/Service/ItemServiceV2.php2
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())