Fixed bug when we delete entry via API

Fixes #4291
This commit is contained in:
Nicolas Lœuillet 2020-04-06 16:11:05 +02:00
parent fbfeb20062
commit a07872238b
No known key found for this signature in database
GPG key ID: 3A8718BE51C3BA8E

View 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;
}