]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/EntryRestController.php
WIP
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / EntryRestController.php
index 632b16d904d898a59b1421d60c713ee75f3f7c96..31bb67fd7d834ed391f08b2c942ca78d6c1056f9 100644 (file)
@@ -297,10 +297,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)) {
@@ -309,7 +318,7 @@ class EntryRestController extends WallabagRestController
 
         $tags = $request->request->get('tags', '');
         if (!empty($tags)) {
-            $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
+            $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
         }
 
         if (!is_null($isStarred)) {
@@ -370,7 +379,7 @@ class EntryRestController extends WallabagRestController
 
         $tags = $request->request->get('tags', '');
         if (!empty($tags)) {
-            $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
+            $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
         }
 
         $em = $this->getDoctrine()->getManager();
@@ -488,7 +497,7 @@ class EntryRestController extends WallabagRestController
 
         $tags = $request->request->get('tags', '');
         if (!empty($tags)) {
-            $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
+            $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
         }
 
         $em = $this->getDoctrine()->getManager();
@@ -617,7 +626,7 @@ class EntryRestController extends WallabagRestController
             $tags = $element->tags;
 
             if (false !== $entry && !(empty($tags))) {
-                $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
+                $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
 
                 $em = $this->getDoctrine()->getManager();
                 $em->persist($entry);