summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2019-03-11 22:36:00 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2019-03-12 13:30:05 +0100
commit9d5ac4b039ecb8f0dd37ede8bc0ae771f1580903 (patch)
treef91d90b0947e1842ee18cc6d68490911ddcc1cbe
parent21b75aadd57c33e70a7b443eb20c096436c0f169 (diff)
Catch FeedIO reader exception.
Closes #413 Closes #412
-rw-r--r--AUTHORS.md42
-rw-r--r--composer.json2
-rw-r--r--composer.lock12
-rw-r--r--lib/Fetcher/Fetcher.php4
-rw-r--r--lib/Fetcher/IFeedFetcher.php4
-rw-r--r--lib/Service/FeedService.php29
-rw-r--r--tests/Unit/Service/FeedServiceTest.php6
7 files changed, 70 insertions, 29 deletions
diff --git a/AUTHORS.md b/AUTHORS.md
index 6b2ba662f..8266c617f 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -2,34 +2,42 @@
* [Bernhard Posselt](mailto:dev@bernhard-posselt.com)
* [Alessandro Cosentino](mailto:cosenal@gmail.com)
* [Robin Appelman](mailto:icewind@owncloud.com)
-* [Nextcloud bot](mailto:bot@nextcloud.com)
* [Gregor Tätzner](mailto:gregor@freenet.de)
-* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net)
* [Morris Jobke](mailto:hey@morrisjobke.de)
+* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net)
+* [Daniel Schaal](mailto:daniel@schaal.email)
+* [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com)
* [Davide Saurino](mailto:davide.saurino@alcacoop.it)
* [raghunayyar](mailto:me@iraghu.com)
* [bastei](mailto:bastei@users.noreply.github.com)
* [Bernhard Posselt](mailto:bep@foryouandyourcustomers.com)
* [Thomas Müller](mailto:thomas.mueller@tmit.eu)
* [Hoàng Đức Hiếu](mailto:hdhoang@zahe.me)
-* [Daniel Schaal](mailto:daniel@schaal.email)
+* [Benjamin Brahmer](mailto:info@b-brahmer.de)
+* [Daniel Opitz](mailto:git@copynpaste.de)
+* [Sean Molenaar](mailto:sean@seanmolenaar.eu)
+* [rakekniven](mailto:mark.ziegler@rakekniven.de)
+* [David-Development](mailto:david-dev@live.de)
+* [Koen Martens](mailto:gmc@sonologic.nl)
* [Lukas Reschke](mailto:lukas@owncloud.com)
+* [Sean Molenaar](mailto:sean@m2mobi.com)
* [Bart Visscher](mailto:bartv@thisnet.nl)
* [Christian Elmer](mailto:christian@keinkurt.de)
+* [IBBoard](mailto:dev@ibboard.co.uk)
* [Thomas Tanghus](mailto:thomas@tanghus.net)
* [Volkan Gezer](mailto:volkangezer@gmail.com)
* [Xéfir Destiny](mailto:xefir@crystalyx.net)
-* [David-Development](mailto:david-dev@live.de)
-* [IBBoard](mailto:dev@ibboard.co.uk)
* [Lars Bensmann](mailto:lars@almosthappy.de)
* [Robin Appelman](mailto:robin@icewind.nl)
* [bluehaze](mailto:francesco.sportolari@gmail.com)
* [darkside40](mailto:darkside401@googlemail.com)
* [Brice Maron](mailto:brice@bmaron.net)
+* [Daniel Opitz](mailto:danopz@users.noreply.github.com)
* [Jakob Sack](mailto:mail@jakobsack.de)
* [Qingping Hou](mailto:dave2008713@gmail.com)
* [Roman](mailto:reverse@jamm.me)
* [Andreas Fischer](mailto:bantu@owncloud.com)
+* [David Guillot](mailto:david@guillot.me)
* [John Kristensen](mailto:john@jerrykan.com)
* [Konrad Graefe](mailto:konradgraefe@aol.com)
* [Loki3000](mailto:github@labcms.ru)
@@ -39,39 +47,63 @@
* [Peter Hedlund](mailto:peter@peterandlinda.com)
* [bbBowser](mailto:carspi@mail.de)
* [benediktb](mailto:benedikt@blablub.de)
+* [coderkun](mailto:olli@coderkun.de)
* [davidak](mailto:git@davidak.de)
* [lsmooth](mailto:ls@lsmooth.de)
* [s17t.net](mailto:mail+github@s17t.net)
* [Alessandro](mailto:cosenal@gmail.com)
+* [Alexander Grüßung](mailto:alexander@gruessung-online.de)
+* [Allan Nordhøy](mailto:epost@anotheragency.no)
* [Alwaysin](mailto:adrien@demma.fr)
* [Andrea Boero](mailto:mail@tsumi.it)
+* [Arthur Schiwon](mailto:blizzz@arthur-schiwon.de)
* [Benedikt Geißler](mailto:benedikt@g5r.eu)
+* [Bernhard Posselt](mailto:bernhard@desktop.localdomain)
* [Colin W](mailto:cwmke@users.noreply.github.com)
+* [Daniel Aleksandersen](mailto:code@daniel.priv.no)
+* [Daniel S](mailto:daniel@while-true-do.org)
+* [Detlev Zundel](mailto:dzu@member.fsf.org)
+* [Doron Behar](mailto:doron.behar@gmail.com)
+* [DriverXX](mailto:thegio.f@gmail.com)
+* [DudleyDursley](mailto:35841630+DudleyDursley@users.noreply.github.com)
* [Felix](mailto:eppfel@users.noreply.github.com)
* [Felix Bartels](mailto:felix@host-consultants.de)
* [Florian Hülsmann](mailto:fh@cbix.de)
+* [Flurin Rindisbacher](mailto:flurischt@users.noreply.github.com)
* [Frank Karlitschek](mailto:frank@owncloud.org)
+* [Hanzei](mailto:Hanzei@users.noreply.github.com)
* [Hendrik Leppelsack](mailto:hendrik@leppelsack.de)
* [Matthias Blümel](mailto:user@inanna.local)
* [Michael Grosser](mailto:github@stp-ip.net)
* [Michael Holley](mailto:michaelwholley@gmail.com)
* [Nick Frey](mailto:nickfrey123@gmail.com)
+* [Oliver Herst](mailto:oliver.herst@googlemail.com)
* [Patrick O'Keeffe](mailto:patricktokeeffe@users.noreply.github.com)
+* [Pierre Ozoux](mailto:pierre@ozoux.net)
* [Piotr Dobrowolski](mailto:admin@tastycode.pl)
* [Raspbeguy](mailto:raspbeguy@users.noreply.github.com)
+* [Roeland Jago Douma](mailto:roeland@famdouma.nl)
+* [Simon Gilliot](mailto:simon@gilliot.fr)
* [TexasGamer](mailto:tpgaubert@gmail.com)
* [The Gitter Badger](mailto:badger@gitter.im)
* [Thomas Wouters](mailto:twouters@users.noreply.github.com)
* [Timo Schmidt](mailto:timo@xinterchange.net)
+* [Welling Guzmán](mailto:WellingGuzman@users.noreply.github.com)
+* [Xaver Maierhofer](mailto:xaver.maierhofer@xwissen.info)
* [Xemle](mailto:xemle@phtagr.org)
+* [YMHuang](mailto:ymhuang@fmbase.tw)
+* [Zach DeCook](mailto:zachdecook@gmail.com)
* [amittel](mailto:arnulf.mittelstaedt@gmail.com)
* [anoy](mailto:anoymouserver@users.noreply.github.com)
+* [b_b](mailto:brunobergot@gmail.com)
* [bjoerns1983](mailto:bjoern@sengotta.net)
+* [blackcrack](mailto:blackcrack@blackysgate.de)
* [comradekingu](mailto:epost@anotheragency.no)
* [joeplus](mailto:joerg@honululu.Speedport_W_723V_1_32_000)
* [kondou](mailto:kondou@ts.unde.re)
* [markusj](mailto:markusj@users.noreply.github.com)
* [repat](mailto:repat@repat.de)
* [ritchiewilson](mailto:rawilson52@gmail.com)
+* [sonologic](mailto:gmc@sonologic.nl)
* [tflidd](mailto:tflidd@aspekte.net)
* [wizdude](mailto:wizdude@users.noreply.github.com) \ No newline at end of file
diff --git a/composer.json b/composer.json
index 4f1e1690f..538ecbc70 100644
--- a/composer.json
+++ b/composer.json
@@ -39,7 +39,7 @@
"ezyang/htmlpurifier": "4.10.0",
"pear/net_url2": "2.2.2",
"riimu/kit-pathjoin": "1.2.0",
- "debril/feed-io": "^3.0",
+ "debril/feed-io": "^3.1",
"arthurhoaro/favicon": "^1.2",
"ext-json": "*"
},
diff --git a/composer.lock b/composer.lock
index 02041b6e0..afc52cd55 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e252c35035e7c61a7b6cb6e27808d732",
+ "content-hash": "2247ef4a89a64d37158df942d780cdfe",
"packages": [
{
"name": "arthurhoaro/favicon",
@@ -58,16 +58,16 @@
},
{
"name": "debril/feed-io",
- "version": "v3.1.1",
+ "version": "v3.1.3",
"source": {
"type": "git",
"url": "https://github.com/alexdebril/feed-io.git",
- "reference": "a79a09a915540b5475b12c82effb3dd43c2b2a0b"
+ "reference": "a0035d9bfe7c9ac1333242447fab781ae89fe8af"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/alexdebril/feed-io/zipball/a79a09a915540b5475b12c82effb3dd43c2b2a0b",
- "reference": "a79a09a915540b5475b12c82effb3dd43c2b2a0b",
+ "url": "https://api.github.com/repos/alexdebril/feed-io/zipball/a0035d9bfe7c9ac1333242447fab781ae89fe8af",
+ "reference": "a0035d9bfe7c9ac1333242447fab781ae89fe8af",
"shasum": ""
},
"require": {
@@ -114,7 +114,7 @@
"news",
"rss"
],
- "time": "2018-06-18T12:31:47+00:00"
+ "time": "2019-03-11T15:08:14+00:00"
},
{
"name": "ezyang/htmlpurifier",
diff --git a/lib/Fetcher/Fetcher.php b/lib/Fetcher/Fetcher.php
index 23f5b57f7..425004680 100644
--- a/lib/Fetcher/Fetcher.php
+++ b/lib/Fetcher/Fetcher.php
@@ -13,6 +13,8 @@
namespace OCA\News\Fetcher;
+use FeedIo\Reader\ReadErrorException;
+
class Fetcher
{
@@ -48,7 +50,7 @@ class Fetcher
* @param string $user if given, basic auth is set for this feed
* @param string $password if given, basic auth is set for this feed. Ignored if user is empty
*
- * @throws FetcherException if FeedIO fails
+ * @throws ReadErrorException if FeedIO fails
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
*/
diff --git a/lib/Fetcher/IFeedFetcher.php b/lib/Fetcher/IFeedFetcher.php
index ecc0ffc16..81bf8526f 100644
--- a/lib/Fetcher/IFeedFetcher.php
+++ b/lib/Fetcher/IFeedFetcher.php
@@ -13,6 +13,8 @@
namespace OCA\News\Fetcher;
+use FeedIo\Reader\ReadErrorException;
+
interface IFeedFetcher
{
@@ -28,7 +30,7 @@ interface IFeedFetcher
*
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
- * @throws FetcherException if the fetcher encounters a problem
+ * @throws ReadErrorException if the Feed-IO fetcher encounters a problem
*/
public function fetch(string $url, bool $favicon, $lastModified, $user, $password): array;
diff --git a/lib/Service/FeedService.php b/lib/Service/FeedService.php
index f46171868..6dee1fd1c 100644
--- a/lib/Service/FeedService.php
+++ b/lib/Service/FeedService.php
@@ -13,6 +13,7 @@
namespace OCA\News\Service;
+use FeedIo\Reader\ReadErrorException;
use HTMLPurifier;
use OCP\ILogger;
@@ -24,7 +25,6 @@ use OCA\News\Db\Item;
use OCA\News\Db\FeedMapper;
use OCA\News\Db\ItemMapper;
use OCA\News\Fetcher\Fetcher;
-use OCA\News\Fetcher\FetcherException;
use OCA\News\Config\Config;
use OCA\News\Utility\Time;
@@ -165,7 +165,7 @@ class FeedService extends Service
$feed->setUnreadCount($unreadCount);
return $feed;
- } catch (FetcherException $ex) {
+ } catch (ReadErrorException $ex) {
$this->logger->debug($ex->getMessage(), $this->loggerParams);
throw new ServiceNotFoundException($ex->getMessage());
}
@@ -300,7 +300,7 @@ class FeedService extends Service
// mark feed as successfully updated
$existingFeed->setUpdateErrorCount(0);
$existingFeed->setLastUpdateError('');
- } catch (FetcherException $ex) {
+ } catch (ReadErrorException $ex) {
$existingFeed->setUpdateErrorCount(
$existingFeed->getUpdateErrorCount() + 1
);
@@ -456,18 +456,21 @@ class FeedService extends Service
}
/**
- * @param $feedId
- * @param $userId
- * @param $diff an array containing the fields to update, e.g.:
- * [
- * 'ordering' => 1,
- * 'fullTextEnabled' => true,
- * 'pinned' => true,
- * 'updateMode' => 0,
- * 'title' => 'title'
- * ]
+ * @param string $feedId ID of the feed.
+ * @param string $userId ID of the user.
+ * @param array $diff An array containing the fields to update, e.g.:
+ * <code>
+ * [
+ * 'ordering' => 1,
+ * 'fullTextEnabled' => true,
+ * 'pinned' => true,
+ * 'updateMode' => 0,
+ * 'title' => 'title'
+ * ]
+ * </code>
*
* @throws ServiceNotFoundException if feed does not exist
+ * @return Feed The patched feed
*/
public function patch($feedId, $userId, $diff = [])
{
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php
index 9b0c50b20..149b3cdaf 100644
--- a/tests/Unit/Service/FeedServiceTest.php
+++ b/tests/Unit/Service/FeedServiceTest.php
@@ -14,6 +14,8 @@
namespace OCA\News\Tests\Unit\Service;
+use FeedIo\Reader\ReadErrorException;
+
use OCA\News\Config\Config;
use OCA\News\Db\FeedMapper;
use OCA\News\Db\ItemMapper;
@@ -114,7 +116,7 @@ class FeedServiceTest extends TestCase
public function testCreateDoesNotFindFeed()
{
- $ex = new FetcherException('hi');
+ $ex = new ReadErrorException('hi');
$url = 'test';
$this->fetcher->expects($this->once())
->method('fetch')
@@ -581,7 +583,7 @@ class FeedServiceTest extends TestCase
$exptectedFeed->setUpdateErrorCount(1);
$exptectedFeed->setLastUpdateError('hi');
- $ex = new FetcherException('hi');
+ $ex = new ReadErrorException('hi');
$this->feedMapper->expects($this->at(0))
->method('find')