forked from wallabag/wallabag
Ensure orphan tag are remove in API
When the association between a tag and an entry is removed, if the tag doesn’t have other entries, we can remove it. Also add more tests for that part and ensure TagControllerTest is isolated from the rest of the test suite (finally!)
This commit is contained in:
@ -63,10 +63,12 @@ class TagController extends Controller
|
||||
$entry->removeTag($tag);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->flush();
|
||||
if (count($tag->getEntries()) == 0) {
|
||||
|
||||
// remove orphan tag in case no entries are associated to it
|
||||
if (count($tag->getEntries()) === 0) {
|
||||
$em->remove($tag);
|
||||
$em->flush();
|
||||
}
|
||||
$em->flush();
|
||||
|
||||
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user