From 4d0ec0e72108ff47952906e5d968a7c3eb0a76f9 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 27 Mar 2016 20:35:56 +0200 Subject: Fix some Scrutinizer issues --- src/Wallabag/ImportBundle/Import/PocketImport.php | 2 +- .../ImportBundle/Import/WallabagV1Import.php | 25 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import') diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 4499ce69..f598e611 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -68,7 +68,7 @@ class PocketImport implements ImportInterface * * @param string $redirectUri Redirect url in case of error * - * @return string request_token for callback method + * @return string|false request_token for callback method */ public function getRequestToken($redirectUri) { diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 173a587f..82160bae 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php @@ -7,7 +7,6 @@ use Psr\Log\NullLogger; use Doctrine\ORM\EntityManager; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\Entity\User; -use Wallabag\CoreBundle\Tools\Utils; use Wallabag\CoreBundle\Helper\ContentProxy; class WallabagV1Import implements ImportInterface @@ -153,19 +152,25 @@ class WallabagV1Import implements ImportInterface continue; } - // @see ContentProxy->updateEntry - $entry = new Entry($this->user); - $entry->setUrl($importedEntry['url']); + $data = [ + 'title' => $importedEntry['title'], + 'html' => $importedEntry['content'], + 'url' => $importedEntry['url'], + 'content_type' => '', + 'language' => '', + ]; + // force content to be refreshed in case on bad fetch in the v1 installation if (in_array($importedEntry['title'], $untitled)) { - $entry = $this->contentProxy->updateEntry($entry, $importedEntry['url']); - } else { - $entry->setContent($importedEntry['content']); - $entry->setTitle($importedEntry['title']); - $entry->setReadingTime(Utils::getReadingTime($importedEntry['content'])); - $entry->setDomainName(parse_url($importedEntry['url'], PHP_URL_HOST)); + $data = []; } + $entry = $this->contentProxy->updateEntry( + new Entry($this->user), + $importedEntry['url'], + $data + ); + if (array_key_exists('tags', $importedEntry) && $importedEntry['tags'] != '') { $this->contentProxy->assignTagsToEntry( $entry, -- cgit v1.2.3 From 8f336fda649c064cabfa692793334067ece780f9 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 27 Mar 2016 23:32:55 +0200 Subject: Tags were not imported in wallabag v2 import Also, simplify exportAs matching format --- .../ImportBundle/Import/WallabagV2Import.php | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import') diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php index 0a32864e..b31d63a3 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php @@ -47,25 +47,29 @@ class WallabagV2Import extends WallabagV1Import implements ImportInterface continue; } - // @see ContentProxy->updateEntry - $entry = new Entry($this->user); - $entry->setUrl($importedEntry['url']); - $entry->setTitle($importedEntry['title']); - $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead); - $entry->setStarred($importedEntry['is_starred']); - $entry->setContent($importedEntry['content']); - $entry->setReadingTime($importedEntry['reading_time']); - $entry->setDomainName($importedEntry['domain_name']); - if (isset($importedEntry['mimetype'])) { - $entry->setMimetype($importedEntry['mimetype']); - } - if (isset($importedEntry['language'])) { - $entry->setLanguage($importedEntry['language']); + $importedEntry['html'] = $importedEntry['content']; + $importedEntry['content_type'] = $importedEntry['mimetype']; + + $entry = $this->contentProxy->updateEntry( + new Entry($this->user), + $importedEntry['url'], + $importedEntry + ); + + if (array_key_exists('tags', $importedEntry) && !empty($importedEntry['tags'])) { + $this->contentProxy->assignTagsToEntry( + $entry, + $importedEntry['tags'] + ); } + if (isset($importedEntry['preview_picture'])) { $entry->setPreviewPicture($importedEntry['preview_picture']); } + $entry->setArchived($importedEntry['is_archived'] || $this->markAsRead); + $entry->setStarred($importedEntry['is_starred']); + $this->em->persist($entry); ++$this->importedEntries; -- cgit v1.2.3