aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php5
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php1
3 files changed, 7 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a7ef381..ef9d2131 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,8 @@
5 5
6### Fixes 6### Fixes
7 7
8 - Fix empty title and domain_name when exception is thrown during fetch [#3442](https://github.com/wallabag/wallabag/pull/3442) 8- Fix empty title and domain_name when exception is thrown during fetch [#3442](https://github.com/wallabag/wallabag/pull/3442)
9- api: copy entry object before sending, to keep id [#3516](https://github.com/wallabag/wallabag/pull/3516)
9 10
10### Changes 11### Changes
11 12
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index acca219f..fc47c479 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -575,6 +575,9 @@ class EntryRestController extends WallabagRestController
575 $this->validateAuthentication(); 575 $this->validateAuthentication();
576 $this->validateUserAccess($entry->getUser()->getId()); 576 $this->validateUserAccess($entry->getUser()->getId());
577 577
578 // We copy $entry to keep id in returned object
579 $e = $entry;
580
578 $em = $this->getDoctrine()->getManager(); 581 $em = $this->getDoctrine()->getManager();
579 $em->remove($entry); 582 $em->remove($entry);
580 $em->flush(); 583 $em->flush();
@@ -582,7 +585,7 @@ class EntryRestController extends WallabagRestController
582 // entry deleted, dispatch event about it! 585 // entry deleted, dispatch event about it!
583 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); 586 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
584 587
585 return $this->sendResponse($entry); 588 return $this->sendResponse($e);
586 } 589 }
587 590
588 /** 591 /**
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 5c7b988c..2e9b9305 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -408,6 +408,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
408 408
409 $this->assertSame($entry->getTitle(), $content['title']); 409 $this->assertSame($entry->getTitle(), $content['title']);
410 $this->assertSame($entry->getUrl(), $content['url']); 410 $this->assertSame($entry->getUrl(), $content['url']);
411 $this->assertSame($entry->getId(), $content['id']);
411 412
412 // We'll try to delete this entry again 413 // We'll try to delete this entry again
413 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json'); 414 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');