$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'));
}
}
- return $this->render('WallabagCoreBundle:Entry:entries.html.twig',[
+ return $this->render('WallabagCoreBundle:Entry:entries.html.twig', [
'form' => null,
'entries' => $entries,
'currentPage' => $page,