Catch FeedIO reader exception.

Closes #413

Closes #412
This commit is contained in:
Sean Molenaar 2019-03-11 22:36:00 +01:00 коммит произвёл Sean Molenaar
Родитель 21b75aadd5
Коммит 9d5ac4b039
7 изменённых файлов: 70 добавлений и 29 удалений

Просмотреть файл

@ -2,34 +2,42 @@
* [Bernhard Posselt](mailto:dev@bernhard-posselt.com) * [Bernhard Posselt](mailto:dev@bernhard-posselt.com)
* [Alessandro Cosentino](mailto:cosenal@gmail.com) * [Alessandro Cosentino](mailto:cosenal@gmail.com)
* [Robin Appelman](mailto:icewind@owncloud.com) * [Robin Appelman](mailto:icewind@owncloud.com)
* [Nextcloud bot](mailto:bot@nextcloud.com)
* [Gregor Tätzner](mailto:gregor@freenet.de) * [Gregor Tätzner](mailto:gregor@freenet.de)
* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net)
* [Morris Jobke](mailto:hey@morrisjobke.de) * [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) * [Davide Saurino](mailto:davide.saurino@alcacoop.it)
* [raghunayyar](mailto:me@iraghu.com) * [raghunayyar](mailto:me@iraghu.com)
* [bastei](mailto:bastei@users.noreply.github.com) * [bastei](mailto:bastei@users.noreply.github.com)
* [Bernhard Posselt](mailto:bep@foryouandyourcustomers.com) * [Bernhard Posselt](mailto:bep@foryouandyourcustomers.com)
* [Thomas Müller](mailto:thomas.mueller@tmit.eu) * [Thomas Müller](mailto:thomas.mueller@tmit.eu)
* [Hoàng Đức Hiếu](mailto:hdhoang@zahe.me) * [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) * [Lukas Reschke](mailto:lukas@owncloud.com)
* [Sean Molenaar](mailto:sean@m2mobi.com)
* [Bart Visscher](mailto:bartv@thisnet.nl) * [Bart Visscher](mailto:bartv@thisnet.nl)
* [Christian Elmer](mailto:christian@keinkurt.de) * [Christian Elmer](mailto:christian@keinkurt.de)
* [IBBoard](mailto:dev@ibboard.co.uk)
* [Thomas Tanghus](mailto:thomas@tanghus.net) * [Thomas Tanghus](mailto:thomas@tanghus.net)
* [Volkan Gezer](mailto:volkangezer@gmail.com) * [Volkan Gezer](mailto:volkangezer@gmail.com)
* [Xéfir Destiny](mailto:xefir@crystalyx.net) * [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) * [Lars Bensmann](mailto:lars@almosthappy.de)
* [Robin Appelman](mailto:robin@icewind.nl) * [Robin Appelman](mailto:robin@icewind.nl)
* [bluehaze](mailto:francesco.sportolari@gmail.com) * [bluehaze](mailto:francesco.sportolari@gmail.com)
* [darkside40](mailto:darkside401@googlemail.com) * [darkside40](mailto:darkside401@googlemail.com)
* [Brice Maron](mailto:brice@bmaron.net) * [Brice Maron](mailto:brice@bmaron.net)
* [Daniel Opitz](mailto:danopz@users.noreply.github.com)
* [Jakob Sack](mailto:mail@jakobsack.de) * [Jakob Sack](mailto:mail@jakobsack.de)
* [Qingping Hou](mailto:dave2008713@gmail.com) * [Qingping Hou](mailto:dave2008713@gmail.com)
* [Roman](mailto:reverse@jamm.me) * [Roman](mailto:reverse@jamm.me)
* [Andreas Fischer](mailto:bantu@owncloud.com) * [Andreas Fischer](mailto:bantu@owncloud.com)
* [David Guillot](mailto:david@guillot.me)
* [John Kristensen](mailto:john@jerrykan.com) * [John Kristensen](mailto:john@jerrykan.com)
* [Konrad Graefe](mailto:konradgraefe@aol.com) * [Konrad Graefe](mailto:konradgraefe@aol.com)
* [Loki3000](mailto:github@labcms.ru) * [Loki3000](mailto:github@labcms.ru)
@ -39,39 +47,63 @@
* [Peter Hedlund](mailto:peter@peterandlinda.com) * [Peter Hedlund](mailto:peter@peterandlinda.com)
* [bbBowser](mailto:carspi@mail.de) * [bbBowser](mailto:carspi@mail.de)
* [benediktb](mailto:benedikt@blablub.de) * [benediktb](mailto:benedikt@blablub.de)
* [coderkun](mailto:olli@coderkun.de)
* [davidak](mailto:git@davidak.de) * [davidak](mailto:git@davidak.de)
* [lsmooth](mailto:ls@lsmooth.de) * [lsmooth](mailto:ls@lsmooth.de)
* [s17t.net](mailto:mail+github@s17t.net) * [s17t.net](mailto:mail+github@s17t.net)
* [Alessandro](mailto:cosenal@gmail.com) * [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) * [Alwaysin](mailto:adrien@demma.fr)
* [Andrea Boero](mailto:mail@tsumi.it) * [Andrea Boero](mailto:mail@tsumi.it)
* [Arthur Schiwon](mailto:blizzz@arthur-schiwon.de)
* [Benedikt Geißler](mailto:benedikt@g5r.eu) * [Benedikt Geißler](mailto:benedikt@g5r.eu)
* [Bernhard Posselt](mailto:bernhard@desktop.localdomain)
* [Colin W](mailto:cwmke@users.noreply.github.com) * [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](mailto:eppfel@users.noreply.github.com)
* [Felix Bartels](mailto:felix@host-consultants.de) * [Felix Bartels](mailto:felix@host-consultants.de)
* [Florian Hülsmann](mailto:fh@cbix.de) * [Florian Hülsmann](mailto:fh@cbix.de)
* [Flurin Rindisbacher](mailto:flurischt@users.noreply.github.com)
* [Frank Karlitschek](mailto:frank@owncloud.org) * [Frank Karlitschek](mailto:frank@owncloud.org)
* [Hanzei](mailto:Hanzei@users.noreply.github.com)
* [Hendrik Leppelsack](mailto:hendrik@leppelsack.de) * [Hendrik Leppelsack](mailto:hendrik@leppelsack.de)
* [Matthias Blümel](mailto:user@inanna.local) * [Matthias Blümel](mailto:user@inanna.local)
* [Michael Grosser](mailto:github@stp-ip.net) * [Michael Grosser](mailto:github@stp-ip.net)
* [Michael Holley](mailto:michaelwholley@gmail.com) * [Michael Holley](mailto:michaelwholley@gmail.com)
* [Nick Frey](mailto:nickfrey123@gmail.com) * [Nick Frey](mailto:nickfrey123@gmail.com)
* [Oliver Herst](mailto:oliver.herst@googlemail.com)
* [Patrick O'Keeffe](mailto:patricktokeeffe@users.noreply.github.com) * [Patrick O'Keeffe](mailto:patricktokeeffe@users.noreply.github.com)
* [Pierre Ozoux](mailto:pierre@ozoux.net)
* [Piotr Dobrowolski](mailto:admin@tastycode.pl) * [Piotr Dobrowolski](mailto:admin@tastycode.pl)
* [Raspbeguy](mailto:raspbeguy@users.noreply.github.com) * [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) * [TexasGamer](mailto:tpgaubert@gmail.com)
* [The Gitter Badger](mailto:badger@gitter.im) * [The Gitter Badger](mailto:badger@gitter.im)
* [Thomas Wouters](mailto:twouters@users.noreply.github.com) * [Thomas Wouters](mailto:twouters@users.noreply.github.com)
* [Timo Schmidt](mailto:timo@xinterchange.net) * [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) * [Xemle](mailto:xemle@phtagr.org)
* [YMHuang](mailto:ymhuang@fmbase.tw)
* [Zach DeCook](mailto:zachdecook@gmail.com)
* [amittel](mailto:arnulf.mittelstaedt@gmail.com) * [amittel](mailto:arnulf.mittelstaedt@gmail.com)
* [anoy](mailto:anoymouserver@users.noreply.github.com) * [anoy](mailto:anoymouserver@users.noreply.github.com)
* [b_b](mailto:brunobergot@gmail.com)
* [bjoerns1983](mailto:bjoern@sengotta.net) * [bjoerns1983](mailto:bjoern@sengotta.net)
* [blackcrack](mailto:blackcrack@blackysgate.de)
* [comradekingu](mailto:epost@anotheragency.no) * [comradekingu](mailto:epost@anotheragency.no)
* [joeplus](mailto:joerg@honululu.Speedport_W_723V_1_32_000) * [joeplus](mailto:joerg@honululu.Speedport_W_723V_1_32_000)
* [kondou](mailto:kondou@ts.unde.re) * [kondou](mailto:kondou@ts.unde.re)
* [markusj](mailto:markusj@users.noreply.github.com) * [markusj](mailto:markusj@users.noreply.github.com)
* [repat](mailto:repat@repat.de) * [repat](mailto:repat@repat.de)
* [ritchiewilson](mailto:rawilson52@gmail.com) * [ritchiewilson](mailto:rawilson52@gmail.com)
* [sonologic](mailto:gmc@sonologic.nl)
* [tflidd](mailto:tflidd@aspekte.net) * [tflidd](mailto:tflidd@aspekte.net)
* [wizdude](mailto:wizdude@users.noreply.github.com) * [wizdude](mailto:wizdude@users.noreply.github.com)

Просмотреть файл

@ -39,7 +39,7 @@
"ezyang/htmlpurifier": "4.10.0", "ezyang/htmlpurifier": "4.10.0",
"pear/net_url2": "2.2.2", "pear/net_url2": "2.2.2",
"riimu/kit-pathjoin": "1.2.0", "riimu/kit-pathjoin": "1.2.0",
"debril/feed-io": "^3.0", "debril/feed-io": "^3.1",
"arthurhoaro/favicon": "^1.2", "arthurhoaro/favicon": "^1.2",
"ext-json": "*" "ext-json": "*"
}, },

12
composer.lock сгенерированный
Просмотреть файл

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "e252c35035e7c61a7b6cb6e27808d732", "content-hash": "2247ef4a89a64d37158df942d780cdfe",
"packages": [ "packages": [
{ {
"name": "arthurhoaro/favicon", "name": "arthurhoaro/favicon",
@ -58,16 +58,16 @@
}, },
{ {
"name": "debril/feed-io", "name": "debril/feed-io",
"version": "v3.1.1", "version": "v3.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/alexdebril/feed-io.git", "url": "https://github.com/alexdebril/feed-io.git",
"reference": "a79a09a915540b5475b12c82effb3dd43c2b2a0b" "reference": "a0035d9bfe7c9ac1333242447fab781ae89fe8af"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/alexdebril/feed-io/zipball/a79a09a915540b5475b12c82effb3dd43c2b2a0b", "url": "https://api.github.com/repos/alexdebril/feed-io/zipball/a0035d9bfe7c9ac1333242447fab781ae89fe8af",
"reference": "a79a09a915540b5475b12c82effb3dd43c2b2a0b", "reference": "a0035d9bfe7c9ac1333242447fab781ae89fe8af",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -114,7 +114,7 @@
"news", "news",
"rss" "rss"
], ],
"time": "2018-06-18T12:31:47+00:00" "time": "2019-03-11T15:08:14+00:00"
}, },
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",

Просмотреть файл

@ -13,6 +13,8 @@
namespace OCA\News\Fetcher; namespace OCA\News\Fetcher;
use FeedIo\Reader\ReadErrorException;
class Fetcher class Fetcher
{ {
@ -48,7 +50,7 @@ class Fetcher
* @param string $user if given, basic auth is set for this feed * @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 * @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 * @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items * element being the Feed and second element being an array of Items
*/ */

Просмотреть файл

@ -13,6 +13,8 @@
namespace OCA\News\Fetcher; namespace OCA\News\Fetcher;
use FeedIo\Reader\ReadErrorException;
interface IFeedFetcher interface IFeedFetcher
{ {
@ -28,7 +30,7 @@ interface IFeedFetcher
* *
* @return array an array containing the new feed and its items, first * @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items * 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; public function fetch(string $url, bool $favicon, $lastModified, $user, $password): array;

Просмотреть файл

@ -13,6 +13,7 @@
namespace OCA\News\Service; namespace OCA\News\Service;
use FeedIo\Reader\ReadErrorException;
use HTMLPurifier; use HTMLPurifier;
use OCP\ILogger; use OCP\ILogger;
@ -24,7 +25,6 @@ use OCA\News\Db\Item;
use OCA\News\Db\FeedMapper; use OCA\News\Db\FeedMapper;
use OCA\News\Db\ItemMapper; use OCA\News\Db\ItemMapper;
use OCA\News\Fetcher\Fetcher; use OCA\News\Fetcher\Fetcher;
use OCA\News\Fetcher\FetcherException;
use OCA\News\Config\Config; use OCA\News\Config\Config;
use OCA\News\Utility\Time; use OCA\News\Utility\Time;
@ -165,7 +165,7 @@ class FeedService extends Service
$feed->setUnreadCount($unreadCount); $feed->setUnreadCount($unreadCount);
return $feed; return $feed;
} catch (FetcherException $ex) { } catch (ReadErrorException $ex) {
$this->logger->debug($ex->getMessage(), $this->loggerParams); $this->logger->debug($ex->getMessage(), $this->loggerParams);
throw new ServiceNotFoundException($ex->getMessage()); throw new ServiceNotFoundException($ex->getMessage());
} }
@ -300,7 +300,7 @@ class FeedService extends Service
// mark feed as successfully updated // mark feed as successfully updated
$existingFeed->setUpdateErrorCount(0); $existingFeed->setUpdateErrorCount(0);
$existingFeed->setLastUpdateError(''); $existingFeed->setLastUpdateError('');
} catch (FetcherException $ex) { } catch (ReadErrorException $ex) {
$existingFeed->setUpdateErrorCount( $existingFeed->setUpdateErrorCount(
$existingFeed->getUpdateErrorCount() + 1 $existingFeed->getUpdateErrorCount() + 1
); );
@ -456,18 +456,21 @@ class FeedService extends Service
} }
/** /**
* @param $feedId * @param string $feedId ID of the feed.
* @param $userId * @param string $userId ID of the user.
* @param $diff an array containing the fields to update, e.g.: * @param array $diff An array containing the fields to update, e.g.:
* [ * <code>
* 'ordering' => 1, * [
* 'fullTextEnabled' => true, * 'ordering' => 1,
* 'pinned' => true, * 'fullTextEnabled' => true,
* 'updateMode' => 0, * 'pinned' => true,
* 'title' => 'title' * 'updateMode' => 0,
* ] * 'title' => 'title'
* ]
* </code>
* *
* @throws ServiceNotFoundException if feed does not exist * @throws ServiceNotFoundException if feed does not exist
* @return Feed The patched feed
*/ */
public function patch($feedId, $userId, $diff = []) public function patch($feedId, $userId, $diff = [])
{ {

Просмотреть файл

@ -14,6 +14,8 @@
namespace OCA\News\Tests\Unit\Service; namespace OCA\News\Tests\Unit\Service;
use FeedIo\Reader\ReadErrorException;
use OCA\News\Config\Config; use OCA\News\Config\Config;
use OCA\News\Db\FeedMapper; use OCA\News\Db\FeedMapper;
use OCA\News\Db\ItemMapper; use OCA\News\Db\ItemMapper;
@ -114,7 +116,7 @@ class FeedServiceTest extends TestCase
public function testCreateDoesNotFindFeed() public function testCreateDoesNotFindFeed()
{ {
$ex = new FetcherException('hi'); $ex = new ReadErrorException('hi');
$url = 'test'; $url = 'test';
$this->fetcher->expects($this->once()) $this->fetcher->expects($this->once())
->method('fetch') ->method('fetch')
@ -581,7 +583,7 @@ class FeedServiceTest extends TestCase
$exptectedFeed->setUpdateErrorCount(1); $exptectedFeed->setUpdateErrorCount(1);
$exptectedFeed->setLastUpdateError('hi'); $exptectedFeed->setLastUpdateError('hi');
$ex = new FetcherException('hi'); $ex = new ReadErrorException('hi');
$this->feedMapper->expects($this->at(0)) $this->feedMapper->expects($this->at(0))
->method('find') ->method('find')