summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bl/feedbl.php2
-rw-r--r--db/itemmapper.php8
-rw-r--r--tests/bl/FeedBlTest.php1
-rw-r--r--tests/db/ItemMapperTest.php9
4 files changed, 13 insertions, 7 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php
index 3f7fe0ceb..5ab4d8953 100644
--- a/bl/feedbl.php
+++ b/bl/feedbl.php
@@ -113,7 +113,7 @@ class FeedBl extends Bl {
$this->itemMapper->insert($item);
} catch(\DatabaseException $ex){
$existing = $this->itemMapper->findByGuidHash(
- $item->getGuidHash(), $userId);
+ $item->getGuidHash(), $feedId, $userId);
$item->setId($existing->getId());
$this->itemMapper->update($item);
}
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 2704b775f..d54bbade1 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -169,9 +169,11 @@ class ItemMapper extends Mapper implements IMapper {
}
- public function findByGuidHash($guidHash, $userId){
- $sql = $this->makeSelectQuery('AND `*PREFIX*news_items`.`guid_hash` = ? ');
- $row = $this->findOneQuery($sql, array($userId, $guidHash));
+ public function findByGuidHash($guidHash, $feedId, $userId){
+ $sql = $this->makeSelectQuery(
+ 'AND `items`.`guid_hash` = ? ' .
+ 'AND `feed`.`id = ? ');
+ $row = $this->findOneQuery($sql, array($userId, $guidHash, $feedId));
$item = new Item();
$item->fromRow($row);
diff --git a/tests/bl/FeedBlTest.php b/tests/bl/FeedBlTest.php
index 2ec3d3e47..b43060112 100644
--- a/tests/bl/FeedBlTest.php
+++ b/tests/bl/FeedBlTest.php
@@ -197,6 +197,7 @@ class FeedBlTest extends \OCA\AppFramework\Utility\TestUtility {
$this->itemMapper->expects($this->once())
->method('findByGuidHash')
->with($this->equalTo($item->getGuidHash()),
+ $this->equalTo($feed->getId()),
$this->equalTo($this->user))
->will($this->returnValue($item));
$this->itemMapper->expects($this->once())
diff --git a/tests/db/ItemMapperTest.php b/tests/db/ItemMapperTest.php
index 7c1cb743e..f528e31c3 100644
--- a/tests/db/ItemMapperTest.php
+++ b/tests/db/ItemMapperTest.php
@@ -249,11 +249,14 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
public function testFindByGuidHash(){
$hash = md5('test');
- $sql = $this->makeSelectQuery('AND `*PREFIX*news_items`.`guid_hash` = ? ');
+ $feedId = 3;
+ $sql = $this->makeSelectQuery(
+ 'AND `items`.`guid_hash` = ? ' .
+ 'AND `feed`.`id = ? ');
- $this->setMapperResult($sql, array($this->userId, $hash), $this->row);
+ $this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row);
- $result = $this->mapper->findByGuidHash($hash, $this->userId);
+ $result = $this->mapper->findByGuidHash($hash, $feedId, $this->userId);
$this->assertEquals($this->items[0], $result);
}