forked from wallabag/wallabag
TagController: fix duplicated tags when renaming them
The fix relies on a workaround available on TagsAssigner, see the AssignTagsToEntry() signature for detail. I replaced the findOneByLabel in the corresponding test to assert that there is no duplicate. Fixes #4216 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
@ -152,6 +152,10 @@ class TagController extends Controller
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$newTagLabel = $form->get('label')->getData();
|
||||
$newTag = new Tag();
|
||||
$newTag->setLabel($newTagLabel);
|
||||
|
||||
$entries = $this->get('wallabag_core.entry_repository')->findAllByTagId(
|
||||
$this->getUser()->getId(),
|
||||
$tag->getId()
|
||||
@ -159,7 +163,8 @@ class TagController extends Controller
|
||||
foreach ($entries as $entry) {
|
||||
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry(
|
||||
$entry,
|
||||
$form->get('label')->getData()
|
||||
$newTagLabel,
|
||||
[$newTag]
|
||||
);
|
||||
$entry->removeTag($tag);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user