summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkesselb <mail@danielkesselberg.de>2019-12-27 03:51:06 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2019-12-27 03:51:06 +0100
commitf045bd0ba337d60b91827c7530f00a780afd7b66 (patch)
tree5be2b45f29f4c1b4534106636d98c6fb99ceb6b1
parent5ab64657bd31de0d86a17612e879e7bf9b165dcf (diff)
Update httpLastModified from the feed response (#594)
LastModified is used (in a feed context to see if a user edited a feed). httpLastModified to store the last-modified response from the source. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
-rwxr-xr-xlib/Fetcher/FeedFetcher.php7
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php9
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php
index 5a0f0e4e7..a1b7e08ec 100755
--- a/lib/Fetcher/FeedFetcher.php
+++ b/lib/Fetcher/FeedFetcher.php
@@ -206,7 +206,7 @@ class FeedFetcher implements IFeedFetcher
$item->setGuid($parsedItem->getPublicId());
$item->setGuidHash(md5($item->getGuid()));
- $lastmodified = $parsedItem->getLastModified() ?? new \DateTime();
+ $lastmodified = $parsedItem->getLastModified() ?? new DateTime();
if ($parsedItem->getValue('pubDate') !== null) {
$pubDT = new DateTime($parsedItem->getValue('pubDate'));
} elseif ($parsedItem->getValue('published') !== null) {
@@ -288,8 +288,9 @@ class FeedFetcher implements IFeedFetcher
$newFeed->setUrl($url); // the url used to add the feed
$newFeed->setLocation($location); // the url where the feed was found
$newFeed->setLink($feed->getLink()); // <link> attribute in the feed
- $lastmodified = $feed->getLastModified() ?? new DateTime();
- $newFeed->setLastModified($lastmodified->getTimestamp());
+ if ($feed->getLastModified() instanceof DateTime) {
+ $newFeed->setHttpLastModified($feed->getLastModified()->format(DateTime::RSS));
+ }
$newFeed->setAdded($this->time->getTime());
if (!$getFavicon) {
diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php
index 0bae8023f..f50912f49 100644
--- a/tests/Unit/Fetcher/FeedFetcherTest.php
+++ b/tests/Unit/Fetcher/FeedFetcherTest.php
@@ -195,10 +195,7 @@ class FeedFetcherTest extends TestCase
$this->feed_link = 'http://tests/';
$this->feed_image = '/an/image';
$this->web_favicon = 'http://anon.google.com';
- $this->modified = $this->getMockBuilder('\DateTime')->getMock();
- $this->modified->expects($this->any())
- ->method('getTimestamp')
- ->will($this->returnValue(3));
+ $this->modified = new DateTime('@3');
$this->encoding = 'UTF-8';
$this->language = 'de-DE';
$this->rtl = false;
@@ -661,7 +658,7 @@ class FeedFetcherTest extends TestCase
$this->feed_mock->expects($this->exactly(1))
->method('getLink')
->will($this->returnValue($this->feed_link));
- $this->feed_mock->expects($this->exactly(1))
+ $this->feed_mock->expects($this->exactly(2))
->method('getLastModified')
->will($this->returnValue($this->modified));
$this->feed_mock->expects($this->exactly(1))
@@ -674,7 +671,7 @@ class FeedFetcherTest extends TestCase
$feed->setLink($this->feed_link);
$feed->setLocation($this->location);
$feed->setUrl($url);
- $feed->setLastModified(3);
+ $feed->setHttpLastModified((new DateTime('@3'))->format(DateTime::RSS));
$feed->setAdded($this->time);
if ($favicon) {
$feed->setFaviconLink('http://anon.google.com');