diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2020-04-04 21:03:22 +0200 |
---|---|---|
committer | Kevin Decherf <kevin@kdecherf.com> | 2020-04-18 18:09:07 +0200 |
commit | 39133eb796996701228501f898b4ef33af8e0fdb (patch) | |
tree | 798462f6e154bf4b5c0f2a17c750a849984b47a6 /src | |
parent | f3565ea2bf24454a4cdda767b3d2c7d5cd0fd51e (diff) | |
download | wallabag-39133eb796996701228501f898b4ef33af8e0fdb.tar.gz wallabag-39133eb796996701228501f898b4ef33af8e0fdb.tar.zst wallabag-39133eb796996701228501f898b4ef33af8e0fdb.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/TagController.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index a6ad131f..c228c27a 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php | |||
@@ -152,6 +152,10 @@ class TagController extends Controller | |||
152 | $form->handleRequest($request); | 152 | $form->handleRequest($request); |
153 | 153 | ||
154 | if ($form->isSubmitted() && $form->isValid()) { | 154 | if ($form->isSubmitted() && $form->isValid()) { |
155 | $newTagLabel = $form->get('label')->getData(); | ||
156 | $newTag = new Tag(); | ||
157 | $newTag->setLabel($newTagLabel); | ||
158 | |||
155 | $entries = $this->get('wallabag_core.entry_repository')->findAllByTagId( | 159 | $entries = $this->get('wallabag_core.entry_repository')->findAllByTagId( |
156 | $this->getUser()->getId(), | 160 | $this->getUser()->getId(), |
157 | $tag->getId() | 161 | $tag->getId() |
@@ -159,7 +163,8 @@ class TagController extends Controller | |||
159 | foreach ($entries as $entry) { | 163 | foreach ($entries as $entry) { |
160 | $this->get('wallabag_core.tags_assigner')->assignTagsToEntry( | 164 | $this->get('wallabag_core.tags_assigner')->assignTagsToEntry( |
161 | $entry, | 165 | $entry, |
162 | $form->get('label')->getData() | 166 | $newTagLabel, |
167 | [$newTag] | ||
163 | ); | 168 | ); |
164 | $entry->removeTag($tag); | 169 | $entry->removeTag($tag); |
165 | } | 170 | } |