mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 01:21:03 +00:00
Replace Wallabag v1 error strings with v2 strings
This commit is contained in:
parent
d0e9b3d640
commit
704803e182
3 changed files with 27 additions and 4 deletions
|
@ -4,6 +4,17 @@ namespace Wallabag\ImportBundle\Import;
|
||||||
|
|
||||||
class WallabagV1Import extends WallabagImport
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -43,10 +54,11 @@ class WallabagV1Import extends WallabagImport
|
||||||
'created_at' => '',
|
'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)) {
|
if (in_array($entry['title'], $this->untitled)) {
|
||||||
$data['title'] = '';
|
$data['title'] = $this->fetchingErrorMessageTitle;
|
||||||
$data['html'] = '';
|
$data['html'] = $this->fetchingErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
|
if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
|
||||||
|
|
|
@ -35,6 +35,8 @@ services:
|
||||||
- "@wallabag_core.content_proxy"
|
- "@wallabag_core.content_proxy"
|
||||||
- "@wallabag_core.tags_assigner"
|
- "@wallabag_core.tags_assigner"
|
||||||
- "@event_dispatcher"
|
- "@event_dispatcher"
|
||||||
|
- "%wallabag_core.fetching_error_message_title%"
|
||||||
|
- "%wallabag_core.fetching_error_message%"
|
||||||
calls:
|
calls:
|
||||||
- [ setLogger, [ "@logger" ]]
|
- [ setLogger, [ "@logger" ]]
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -19,6 +19,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
|
||||||
protected $contentProxy;
|
protected $contentProxy;
|
||||||
protected $tagsAssigner;
|
protected $tagsAssigner;
|
||||||
protected $uow;
|
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)
|
private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +60,14 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
|
||||||
->expects($this->exactly($dispatched))
|
->expects($this->exactly($dispatched))
|
||||||
->method('dispatch');
|
->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();
|
$this->logHandler = new TestHandler();
|
||||||
$logger = new Logger('test', [$this->logHandler]);
|
$logger = new Logger('test', [$this->logHandler]);
|
||||||
|
|
Loading…
Reference in a new issue