diff options
author | Benjamin Brahmer <info@b-brahmer.de> | 2022-08-04 19:21:32 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2022-08-04 19:33:29 +0200 |
commit | e99728abae73ce7276d84a0706f48de5965de4bf (patch) | |
tree | c026fb348a4303c5b1024076f03db72eca7a8f7c | |
parent | 390efb9806d196ff5f6a75382405554b499c7390 (diff) |
change autodiscover behaviour to only run if the provided url is not already a feed
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/Service/FeedServiceV2.php | 23 |
2 files changed, 16 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d95a84d9..fbc2aaeac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 # Unreleased ## [18.x.x] ### Changed - +- Change autodiscover to only run after fetching the given url has failed (#1860) ### Fixed # Releases diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php index bb1be8dcb..1d78c1549 100644 --- a/lib/Service/FeedServiceV2.php +++ b/lib/Service/FeedServiceV2.php @@ -196,13 +196,6 @@ class FeedServiceV2 extends Service throw new ServiceConflictException('Feed with this URL exists'); } - if ($full_discover) { - $feeds = $this->explorer->discover($feedUrl); - if ($feeds !== []) { - $feedUrl = array_shift($feeds); - } - } - try { /** * @var Feed $feed @@ -211,7 +204,21 @@ class FeedServiceV2 extends Service list($feed, $items) = $this->feedFetcher->fetch($feedUrl, $full_text, $user, $password); } catch (ReadErrorException $ex) { $this->logger->debug($ex->getMessage()); - throw new ServiceNotFoundException($ex->getMessage()); + # the url did not lead to a valid feed, try autodiscover + if ($full_discover) { + $this->logger->warning("No valid feed found at URL, attempting auto discovery"); + $feeds = $this->explorer->discover($feedUrl); + if ($feeds !== []) { + $feedUrl = array_shift($feeds); + } + try { + list($feed, $items) = $this->feedFetcher->fetch($feedUrl, $full_text, $user, $password); + } catch (ReadErrorException $ex) { + throw new ServiceNotFoundException($ex->getMessage()); + } + } else { + throw new ServiceNotFoundException($ex->getMessage()); + } } if ($feed === null) { |