]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Retain imported content if fetching fails, fixes #2658
authorJerome Charaoui <jerome@riseup.net>
Sat, 3 Dec 2016 03:41:35 +0000 (22:41 -0500)
committerJerome Charaoui <jerome@riseup.net>
Sat, 3 Dec 2016 03:41:35 +0000 (22:41 -0500)
src/Wallabag/CoreBundle/Helper/ContentProxy.php
src/Wallabag/CoreBundle/Resources/config/services.yml

index fd059325458892c33dcaf576593839e42766d5b6..77acbd6c2577b11ac5b0f048e0531bbf74837c2d 100644 (file)
@@ -21,14 +21,16 @@ class ContentProxy
     protected $logger;
     protected $tagRepository;
     protected $mimeGuesser;
+    protected $fetchingErrorMessage;
 
-    public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger)
+    public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger, $fetchingErrorMessage)
     {
         $this->graby = $graby;
         $this->tagger = $tagger;
         $this->logger = $logger;
         $this->tagRepository = $tagRepository;
         $this->mimeGuesser = new MimeTypeExtensionGuesser();
+        $this->fetchingErrorMessage = $fetchingErrorMessage;
     }
 
     /**
@@ -48,7 +50,10 @@ class ContentProxy
     {
         // do we have to fetch the content or the provided one is ok?
         if (empty($content) || false === $this->validateContent($content)) {
-            $content = $this->graby->fetchContent($url);
+            $fetchedContent = $this->graby->fetchContent($url);
+            if (empty($content) || $fetchedContent['html'] !== $this->fetchingErrorMessage) {
+                $content = $fetchedContent;
+            }
         }
 
         $title = $content['title'];
index bcf0c9cab338748831df21ba5f2164b9ae385ca5..fadd5e490d4083048e3599cb9359826c54f423cb 100644 (file)
@@ -86,6 +86,7 @@ services:
             - "@wallabag_core.rule_based_tagger"
             - "@wallabag_core.tag_repository"
             - "@logger"
+            - '%wallabag_core.fetching_error_message%'
 
     wallabag_core.rule_based_tagger:
         class: Wallabag\CoreBundle\Helper\RuleBasedTagger