summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-11-13 14:14:38 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-11-13 14:14:38 +0100
commit631a1e2baf5e8332bd3034de0022669eca0636fd (patch)
treecb34cd1183d25e4d40f399879381d0c08a2c376e
parentb793f892463a691a4b25bc59add168669720850a (diff)
dont set guidHash when setting guid to avoid overwriting different guid hashes that come from the db
-rw-r--r--db/item.php9
-rw-r--r--fetcher/feedfetcher.php1
-rw-r--r--tests/integration/bootstrap.php1
-rw-r--r--tests/integration/db/ItemMapperTest.php1
-rw-r--r--tests/unit/db/ItemTest.php8
-rw-r--r--tests/unit/fetcher/FeedFetcherTest.php1
-rw-r--r--tests/unit/service/FeedServiceTest.php2
7 files changed, 8 insertions, 15 deletions
diff --git a/db/item.php b/db/item.php
index 452075d05..d5fa83286 100644
--- a/db/item.php
+++ b/db/item.php
@@ -162,6 +162,7 @@ class Item extends Entity implements IAPI, \JsonSerializable {
public static function fromImport($import) {
$item = new static();
$item->setGuid($import['guid']);
+ $item->setGuidHash($import['guid']);
$item->setUrl($import['url']);
$item->setTitle($import['title']);
$item->setAuthor($import['author']);
@@ -202,14 +203,6 @@ class Item extends Entity implements IAPI, \JsonSerializable {
}
- public function setGuid($guid) {
- parent::setGuid($guid);
-
- // not needed to hash again because picofeed hashes the id anyways
- $this->setGuidHash($guid);
- }
-
-
public function setBody($body) {
// FIXME: this should not happen if the target="_blank" is already
// on the link
diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php
index f877eb97c..faf473475 100644
--- a/fetcher/feedfetcher.php
+++ b/fetcher/feedfetcher.php
@@ -147,6 +147,7 @@ class FeedFetcher implements IFeedFetcher {
$item->setUnread();
$item->setUrl($parsedItem->getUrl());
$item->setGuid($parsedItem->getId());
+ $item->setGuidHash($item->getGuid());
$item->setPubDate($parsedItem->getDate());
$item->setLastModified($this->time->getTime());
diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php
index fb050dea1..80e1a5d0d 100644
--- a/tests/integration/bootstrap.php
+++ b/tests/integration/bootstrap.php
@@ -143,6 +143,7 @@ class NewsIntegrationTest extends \PHPUnit_Framework_TestCase {
$newItem->setTitle($item['title']);
$newItem->setAuthor($item['author']);
$newItem->setGuid($item['guid']);
+ $newItem->setGuidHash($item['guid']);
$newItem->setUrl($item['url']);
$newItem->setPubDate($item['pubDate']);
$newItem->setLastModified($item['lastModified']);
diff --git a/tests/integration/db/ItemMapperTest.php b/tests/integration/db/ItemMapperTest.php
index 20ded2ead..7989eb2e7 100644
--- a/tests/integration/db/ItemMapperTest.php
+++ b/tests/integration/db/ItemMapperTest.php
@@ -13,6 +13,7 @@ class ItemMapperTest extends NewsIntegrationTest {
$item = new Item();
$item->setTitle('my title thats long');
$item->setGuid('a doner');
+ $item->setGuidHash('a doner');
$item->setFeedId($feedId);
$item->setUnread();
$item->setBody('Döner');
diff --git a/tests/unit/db/ItemTest.php b/tests/unit/db/ItemTest.php
index 6d1a1d87a..4ced884c8 100644
--- a/tests/unit/db/ItemTest.php
+++ b/tests/unit/db/ItemTest.php
@@ -166,6 +166,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
private function createImportItem($isRead) {
$item = new Item();
$item->setGuid('guid');
+ $item->setGuidHash('guid');
$item->setUrl('https://google');
$item->setTitle('title');
$item->setAuthor('author');
@@ -260,13 +261,6 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
}
- public function testSetGuidUpdatesHash() {
- $item = new Item();
- $item->setGuid('http://test');
- $this->assertEquals('http://test', $item->getGuidHash());
- }
-
-
public function testMakeLinksInBodyOpenNewTab() {
$item = new Item();
$item->setBody("<a href=\"test\">ha</a>");
diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php
index a9e29de0c..5f68ff333 100644
--- a/tests/unit/fetcher/FeedFetcherTest.php
+++ b/tests/unit/fetcher/FeedFetcherTest.php
@@ -208,6 +208,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
$item->setUrl($this->permalink);
$item->setTitle('my<\' title');
$item->setGuid($this->guid);
+ $item->setGuidHash($this->guid);
$item->setBody($this->body);
$item->setLastModified($this->time);
diff --git a/tests/unit/service/FeedServiceTest.php b/tests/unit/service/FeedServiceTest.php
index ff00104e9..3a53a0122 100644
--- a/tests/unit/service/FeedServiceTest.php
+++ b/tests/unit/service/FeedServiceTest.php
@@ -548,6 +548,7 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$item->setFeedId(3);
$item->setAuthor('john');
$item->setGuid('s');
+ $item->setGuidHash('s');
$item->setTitle('hey');
$item->setPubDate(333);
$item->setBody('come over');
@@ -603,6 +604,7 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$item->setFeedId(3);
$item->setAuthor('john');
$item->setGuid('s');
+ $item->setGuidHash('s');
$item->setTitle('hey');
$item->setPubDate(333);
$item->setBody('come over');