]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fixed bug when we delete entry via API 4316/head
authorNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 6 Apr 2020 14:11:05 +0000 (16:11 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Mon, 6 Apr 2020 14:11:05 +0000 (16:11 +0200)
Fixes #4291

src/Wallabag/ApiBundle/Controller/EntryRestController.php

index c09fdaebb5c6af02e154cea956db941ec5bb25b6..5158171ea47a73066cdfb29890968df3b31733d0 100644 (file)
@@ -239,12 +239,12 @@ class EntryRestController extends WallabagRestController
             $results[$key]['url'] = $url;
 
             if (false !== $entry) {
+                // entry deleted, dispatch event about it!
+                $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
+
                 $em = $this->getDoctrine()->getManager();
                 $em->remove($entry);
                 $em->flush();
-
-                // entry deleted, dispatch event about it!
-                $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
             }
 
             $results[$key]['entry'] = $entry instanceof Entry ? true : false;
@@ -610,13 +610,13 @@ class EntryRestController extends WallabagRestController
             $response = $this->sendResponse($e);
         }
 
+        // entry deleted, dispatch event about it!
+        $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
+
         $em = $this->getDoctrine()->getManager();
         $em->remove($entry);
         $em->flush();
 
-        // entry deleted, dispatch event about it!
-        $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
-
         return $response;
     }