]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
api: copy entry object before sending, to keep id 3516/head
authorKevin Decherf <kevin@kdecherf.com>
Sun, 17 Dec 2017 20:05:25 +0000 (21:05 +0100)
committerKevin Decherf <kevin@kdecherf.com>
Sun, 17 Dec 2017 20:07:46 +0000 (21:07 +0100)
Workaround for https://github.com/wallabag/android-app/issues/646

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
CHANGELOG.md
src/Wallabag/ApiBundle/Controller/EntryRestController.php
tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php

index 1a7ef3818f8173c51700d066060ba7c86100a2b7..ef9d2131caba16d997c9465225f713821ec3a180 100644 (file)
@@ -5,7 +5,8 @@
 
 ### Fixes
 
- - Fix empty title and domain_name when exception is thrown during fetch [#3442](https://github.com/wallabag/wallabag/pull/3442)
+- Fix empty title and domain_name when exception is thrown during fetch [#3442](https://github.com/wallabag/wallabag/pull/3442)
+- api: copy entry object before sending, to keep id [#3516](https://github.com/wallabag/wallabag/pull/3516)
 
 ### Changes
 
index acca219fec733aabaf809d346dcfbb102c64891a..fc47c479ff4bc0df926c2acde344e239eb0e7366 100644 (file)
@@ -575,6 +575,9 @@ class EntryRestController extends WallabagRestController
         $this->validateAuthentication();
         $this->validateUserAccess($entry->getUser()->getId());
 
+        // We copy $entry to keep id in returned object
+        $e = $entry;
+
         $em = $this->getDoctrine()->getManager();
         $em->remove($entry);
         $em->flush();
@@ -582,7 +585,7 @@ class EntryRestController extends WallabagRestController
         // entry deleted, dispatch event about it!
         $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
 
-        return $this->sendResponse($entry);
+        return $this->sendResponse($e);
     }
 
     /**
index 5c7b988c97b609396b6ad481615abf252152ec4a..2e9b93050e335456ca723d926ac40bbde001a727 100644 (file)
@@ -408,6 +408,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
 
         $this->assertSame($entry->getTitle(), $content['title']);
         $this->assertSame($entry->getUrl(), $content['url']);
+        $this->assertSame($entry->getId(), $content['id']);
 
         // We'll try to delete this entry again
         $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');