]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/TagController.php
TagController: prevent tag deletion when renaming a tag with the same label
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / TagController.php
index c228c27a9f8c1018bdbef3f3c03e190d1154ce8e..f7b78f5d3bea3354726ccc5ad3fc491f7dd764db 100644 (file)
@@ -151,7 +151,10 @@ class TagController extends Controller
         $form = $this->createForm(RenameTagType::class, new Tag());
         $form->handleRequest($request);
 
-        if ($form->isSubmitted() && $form->isValid()) {
+        if ($form->isSubmitted()
+            && $form->isValid()
+            && $form->get('label')->getData() !== $tag->getLabel()
+           ) {
             $newTagLabel = $form->get('label')->getData();
             $newTag = new Tag();
             $newTag->setLabel($newTagLabel);
@@ -171,12 +174,12 @@ class TagController extends Controller
 
             $em = $this->getDoctrine()->getManager();
             $em->flush();
-        }
 
-        $this->get('session')->getFlashBag()->add(
-            'notice',
-            'flashes.tag.notice.tag_renamed'
-        );
+            $this->get('session')->getFlashBag()->add(
+                'notice',
+                'flashes.tag.notice.tag_renamed'
+            );
+        }
 
         $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true);