diff options
author | Jerome Charaoui <jerome@riseup.net> | 2016-12-02 22:41:35 -0500 |
---|---|---|
committer | Jerome Charaoui <jerome@riseup.net> | 2016-12-02 22:41:35 -0500 |
commit | 29dca43236001221be947179df0caa8aee966f6d (patch) | |
tree | ff27f5ae975b865d96b53dc87caabdfc5189fb1f /src/Wallabag/CoreBundle/Helper/ContentProxy.php | |
parent | 1093e979ff49f9072c30d1d576c6adf1f8e76bdf (diff) | |
download | wallabag-29dca43236001221be947179df0caa8aee966f6d.tar.gz wallabag-29dca43236001221be947179df0caa8aee966f6d.tar.zst wallabag-29dca43236001221be947179df0caa8aee966f6d.zip |
Retain imported content if fetching fails, fixes #2658
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/ContentProxy.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/ContentProxy.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index fd059325..77acbd6c 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -21,14 +21,16 @@ class ContentProxy | |||
21 | protected $logger; | 21 | protected $logger; |
22 | protected $tagRepository; | 22 | protected $tagRepository; |
23 | protected $mimeGuesser; | 23 | protected $mimeGuesser; |
24 | protected $fetchingErrorMessage; | ||
24 | 25 | ||
25 | public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger) | 26 | public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger, $fetchingErrorMessage) |
26 | { | 27 | { |
27 | $this->graby = $graby; | 28 | $this->graby = $graby; |
28 | $this->tagger = $tagger; | 29 | $this->tagger = $tagger; |
29 | $this->logger = $logger; | 30 | $this->logger = $logger; |
30 | $this->tagRepository = $tagRepository; | 31 | $this->tagRepository = $tagRepository; |
31 | $this->mimeGuesser = new MimeTypeExtensionGuesser(); | 32 | $this->mimeGuesser = new MimeTypeExtensionGuesser(); |
33 | $this->fetchingErrorMessage = $fetchingErrorMessage; | ||
32 | } | 34 | } |
33 | 35 | ||
34 | /** | 36 | /** |
@@ -48,7 +50,10 @@ class ContentProxy | |||
48 | { | 50 | { |
49 | // do we have to fetch the content or the provided one is ok? | 51 | // do we have to fetch the content or the provided one is ok? |
50 | if (empty($content) || false === $this->validateContent($content)) { | 52 | if (empty($content) || false === $this->validateContent($content)) { |
51 | $content = $this->graby->fetchContent($url); | 53 | $fetchedContent = $this->graby->fetchContent($url); |
54 | if (empty($content) || $fetchedContent['html'] !== $this->fetchingErrorMessage) { | ||
55 | $content = $fetchedContent; | ||
56 | } | ||
52 | } | 57 | } |
53 | 58 | ||
54 | $title = $content['title']; | 59 | $title = $content['title']; |