From 08f29ae7b6af585f3af1dd2f8b01854fb0985668 Mon Sep 17 00:00:00 2001 From: adev Date: Mon, 8 May 2017 12:35:02 +0200 Subject: Create a new entry via API even when its content can't be retrieved Fix #2988 --- .../ApiBundle/Controller/EntryRestController.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 2c2ec0c1..e9e1aca3 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -199,10 +199,19 @@ class EntryRestController extends WallabagRestController $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); if (false === $entry) { - $entry = $this->get('wallabag_core.content_proxy')->updateEntry( - new Entry($this->getUser()), - $url - ); + $entry = new Entry($this->getUser()); + try { + $entry = $this->get('wallabag_core.content_proxy')->updateEntry( + $entry, + $url + ); + } catch (\Exception $e) { + $this->get('logger')->error('Error while saving an entry', [ + 'exception' => $e, + 'entry' => $entry, + ]); + $entry->setUrl($url); + } } if (!is_null($title)) { -- cgit v1.2.3