mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-05-07 01:34:06 +02:00
fix multiple results for guid_hash
Signed-off-by: anoy <anoymouserver+github@mailbox.org>
This commit is contained in:
parent
a74491ecde
commit
1fcab6e6c6
lib
@ -99,6 +99,7 @@ class ItemMapperV2 extends NewsMapperV2
|
|||||||
/**
|
/**
|
||||||
* Find an item by a GUID hash.
|
* Find an item by a GUID hash.
|
||||||
*
|
*
|
||||||
|
* @param int $feedId ID of the feed
|
||||||
* @param string $guidHash hash to find with
|
* @param string $guidHash hash to find with
|
||||||
*
|
*
|
||||||
* @return Item|Entity
|
* @return Item|Entity
|
||||||
@ -106,12 +107,14 @@ class ItemMapperV2 extends NewsMapperV2
|
|||||||
* @throws DoesNotExistException
|
* @throws DoesNotExistException
|
||||||
* @throws MultipleObjectsReturnedException
|
* @throws MultipleObjectsReturnedException
|
||||||
*/
|
*/
|
||||||
public function findByGuidHash(string $guidHash): Item
|
public function findByGuidHash(int $feedId, string $guidHash): Item
|
||||||
{
|
{
|
||||||
$builder = $this->db->getQueryBuilder();
|
$builder = $this->db->getQueryBuilder();
|
||||||
$builder->addSelect('*')
|
$builder->addSelect('*')
|
||||||
->from($this->tableName)
|
->from($this->tableName)
|
||||||
|
->andWhere('feed_id = :feed_id')
|
||||||
->andWhere('guid_hash = :guid_hash')
|
->andWhere('guid_hash = :guid_hash')
|
||||||
|
->setParameter(':feed_id', $feedId, IQueryBuilder::PARAM_INT)
|
||||||
->setParameter(':guid_hash', $guidHash, IQueryBuilder::PARAM_STR);
|
->setParameter(':guid_hash', $guidHash, IQueryBuilder::PARAM_STR);
|
||||||
|
|
||||||
return $this->findEntity($builder);
|
return $this->findEntity($builder);
|
||||||
|
@ -75,7 +75,7 @@ class ItemServiceV2 extends Service
|
|||||||
public function insertOrUpdate(Item $item)
|
public function insertOrUpdate(Item $item)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$db_item = $this->mapper->findByGuidHash($item->getGuidHash());
|
$db_item = $this->mapper->findByGuidHash($item->getFeedId(), $item->getGuidHash());
|
||||||
|
|
||||||
// Transfer user modifications
|
// Transfer user modifications
|
||||||
$item->setUnread($db_item->isUnread())
|
$item->setUnread($db_item->isUnread())
|
||||||
|
Loading…
Reference in New Issue
Block a user