forked from wallabag/wallabag
Avoid breaking import when fetching fail
graby will throw an Exception in some case (like a bad url, a restricted url or a secured pdf). Import doesn't handle that case and break the whole import. With that commit the import isn't stopped but the entry is just skipped. Also, as a bonus, I've added extra test on WallabagImportV2 when the json is empty.
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Wallabag\ImportBundle\Import;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use GuzzleHttp\Client;
|
||||
@ -12,12 +11,9 @@ use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Helper\ContentProxy;
|
||||
use Craue\ConfigBundle\Util\Config;
|
||||
|
||||
class PocketImport implements ImportInterface
|
||||
class PocketImport extends AbstractImport
|
||||
{
|
||||
private $user;
|
||||
private $em;
|
||||
private $contentProxy;
|
||||
private $logger;
|
||||
private $client;
|
||||
private $consumerKey;
|
||||
private $skippedEntries = 0;
|
||||
@ -34,11 +30,6 @@ class PocketImport implements ImportInterface
|
||||
$this->logger = new NullLogger();
|
||||
}
|
||||
|
||||
public function setLogger(LoggerInterface $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -219,7 +210,13 @@ class PocketImport implements ImportInterface
|
||||
}
|
||||
|
||||
$entry = new Entry($this->user);
|
||||
$entry = $this->contentProxy->updateEntry($entry, $url);
|
||||
$entry = $this->fetchContent($entry, $url);
|
||||
|
||||
// jump to next entry in case of problem while getting content
|
||||
if (false === $entry) {
|
||||
++$this->skippedEntries;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
|
||||
if ($pocketEntry['status'] == 1 || $this->markAsRead) {
|
||||
|
||||
Reference in New Issue
Block a user