summaryrefslogtreecommitdiffstats
path: root/lib/Fetcher/FeedFetcher.php
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-09-28 21:07:24 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-29 13:02:03 +0200
commitbc01761221384c0bbac0297d38e85bcaa6286a9a (patch)
treebea5acc2db33186982ba94a4270c9eb277c8f0b3 /lib/Fetcher/FeedFetcher.php
parentd00d1ab2a28f428223e52b17052c072c64784016 (diff)
Fix repair step and test it
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Fetcher/FeedFetcher.php')
-rwxr-xr-xlib/Fetcher/FeedFetcher.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php
index 4e93424ba..5a84e2170 100755
--- a/lib/Fetcher/FeedFetcher.php
+++ b/lib/Fetcher/FeedFetcher.php
@@ -75,8 +75,14 @@ class FeedFetcher implements IFeedFetcher
*
* @inheritdoc
*/
- public function fetch(string $url, bool $favicon, $lastModified, bool $fullTextEnabled, $user, $password): array
- {
+ public function fetch(
+ string $url,
+ bool $favicon,
+ ?string $lastModified,
+ bool $fullTextEnabled,
+ ?string $user,
+ ?string $password
+ ): array {
$url2 = new Net_URL2($url);
if (!empty($user) && !empty(trim($user))) {
$url2->setUserinfo(urlencode($user), urlencode($password));
@@ -148,7 +154,7 @@ class FeedFetcher implements IFeedFetcher
*
* @return string
*/
- private function decodeTwice($string): string
+ private function decodeTwice(string $string): string
{
return html_entity_decode(
html_entity_decode(
@@ -195,12 +201,12 @@ class FeedFetcher implements IFeedFetcher
* Build an item based on a feed.
*
* @param ItemInterface $parsedItem The item to use
- * @param string $body Text of the item, if not provided use description from $parsedItem
+ * @param string|null $body Text of the item, if not provided use description from $parsedItem
* @param bool $RTL True if the feed is RTL (Right-to-left)
*
* @return Item
*/
- protected function buildItem(ItemInterface $parsedItem, string $body = null, bool $RTL = false): Item
+ protected function buildItem(ItemInterface $parsedItem, ?string $body = null, bool $RTL = false): Item
{
$item = new Item();
$item->setUnread(true);
@@ -208,18 +214,18 @@ 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) {
$pubDT = new DateTime($parsedItem->getValue('published'));
} else {
- $pubDT = $lastmodified;
+ $pubDT = $lastModified;
}
$item->setPubDate($pubDT->getTimestamp());
- $item->setLastModified($lastmodified->getTimestamp());
+ $item->setLastModified($lastModified->getTimestamp());
$item->setRtl($RTL);
// unescape content because angularjs helps against XSS