From a19caf8a37dfd59a4e270507ec08e9fc259e3e1e Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 4 Apr 2020 22:08:08 +0200 Subject: TagController: prevent tag deletion when renaming a tag with the same label Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Controller/TagController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index c228c27a..f7b78f5d 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -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); -- cgit v1.2.3