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 | |
parent | 1093e979ff49f9072c30d1d576c6adf1f8e76bdf (diff) | |
download | wallabag-29dca43236001221be947179df0caa8aee966f6d.tar.gz wallabag-29dca43236001221be947179df0caa8aee966f6d.tar.zst wallabag-29dca43236001221be947179df0caa8aee966f6d.zip |
Retain imported content if fetching fails, fixes #2658
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/ContentProxy.php | 9 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/config/services.yml | 1 |
2 files changed, 8 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']; |
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index bcf0c9ca..fadd5e49 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -86,6 +86,7 @@ services: | |||
86 | - "@wallabag_core.rule_based_tagger" | 86 | - "@wallabag_core.rule_based_tagger" |
87 | - "@wallabag_core.tag_repository" | 87 | - "@wallabag_core.tag_repository" |
88 | - "@logger" | 88 | - "@logger" |
89 | - '%wallabag_core.fetching_error_message%' | ||
89 | 90 | ||
90 | wallabag_core.rule_based_tagger: | 91 | wallabag_core.rule_based_tagger: |
91 | class: Wallabag\CoreBundle\Helper\RuleBasedTagger | 92 | class: Wallabag\CoreBundle\Helper\RuleBasedTagger |