1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

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:
Kevin Decherf 2020-04-04 21:03:22 +02:00
parent f3565ea2bf
commit 39133eb796
2 changed files with 37 additions and 8 deletions

View file

@ -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);
}