]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Replace Wallabag v1 error strings with v2 strings
authorJerome Charaoui <jerome@riseup.net>
Fri, 16 Dec 2016 14:46:21 +0000 (09:46 -0500)
committerJeremy Benoist <jbenoist@20minutes.fr>
Thu, 1 Jun 2017 07:48:14 +0000 (09:48 +0200)
src/Wallabag/ImportBundle/Import/WallabagV1Import.php
src/Wallabag/ImportBundle/Resources/config/services.yml
tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php

index 59e3ce026c0ae6d76b79c5f9535d36be11ece5d1..872fd642f5b6465773773cd5d8584547de56dbca 100644 (file)
@@ -4,6 +4,17 @@ namespace Wallabag\ImportBundle\Import;
 
 class WallabagV1Import extends WallabagImport
 {
+    protected $fetchingErrorMessage;
+    protected $fetchingErrorMessageTitle;
+
+    public function __construct($em, $contentProxy, $eventDispatcher, $fetchingErrorMessageTitle, $fetchingErrorMessage)
+    {
+        $this->fetchingErrorMessageTitle = $fetchingErrorMessageTitle;
+        $this->fetchingErrorMessage = $fetchingErrorMessage;
+
+        parent::__construct($em, $contentProxy, $eventDispatcher);
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -43,10 +54,11 @@ class WallabagV1Import extends WallabagImport
             'created_at' => '',
         ];
 
-        // force content to be refreshed in case on bad fetch in the v1 installation
+        // In case of a bad fetch in v1, replace title and content with v2 error strings
+        // If fetching fails again, they will get this instead of the v1 strings
         if (in_array($entry['title'], $this->untitled)) {
-            $data['title'] = '';
-            $data['html'] = '';
+            $data['title'] = $this->fetchingErrorMessageTitle;
+            $data['html'] = $this->fetchingErrorMessage;
         }
 
         if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
index 661dc7e1d6c1a293eb4b2250fda4e56d3873afd0..b224a6a2341266eefa6cfde691f9f5d9463a7862 100644 (file)
@@ -35,6 +35,8 @@ services:
             - "@wallabag_core.content_proxy"
             - "@wallabag_core.tags_assigner"
             - "@event_dispatcher"
+            - "%wallabag_core.fetching_error_message_title%"
+            - "%wallabag_core.fetching_error_message%"
         calls:
             - [ setLogger, [ "@logger" ]]
         tags:
index f23cb74894f0c08d39ec9da96ab5176c9c00ebb9..3b2375a19a5e5bfea78a53cba51301946ccff728 100644 (file)
@@ -19,6 +19,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
     protected $contentProxy;
     protected $tagsAssigner;
     protected $uow;
+    protected $fetchingErrorMessageTitle = 'No title found';
+    protected $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
 
     private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
     {
@@ -58,7 +60,14 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
             ->expects($this->exactly($dispatched))
             ->method('dispatch');
 
-        $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+        $wallabag = new WallabagV1Import(
+            $this->em,
+            $this->contentProxy,
+            $this->tagsAssigner,
+            $dispatcher,
+            $this->fetchingErrorMessageTitle,
+            $this->fetchingErrorMessage
+        );
 
         $this->logHandler = new TestHandler();
         $logger = new Logger('test', [$this->logHandler]);