aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-09 18:32:17 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-09 18:55:21 +0200
commitb4fcd60e7f217bf0b23fa99c83698e7407bee54b (patch)
treea3e1ff91ca65b3eeb28aaa5bf10421ad91b3e25e /src/Wallabag
parent4d318f37555772e43906d917a1c8594cec040acf (diff)
downloadwallabag-b4fcd60e7f217bf0b23fa99c83698e7407bee54b.tar.gz
wallabag-b4fcd60e7f217bf0b23fa99c83698e7407bee54b.tar.zst
wallabag-b4fcd60e7f217bf0b23fa99c83698e7407bee54b.zip
Avoid tag duplication when tagging all articles
Mostly when the tag doesn’t yet exist. It was created each time it matche the rule… glups.
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 239d09ae..b490e209 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -55,6 +55,7 @@ class RuleBasedTagger
55 { 55 {
56 $rules = $this->getRulesForUser($user); 56 $rules = $this->getRulesForUser($user);
57 $entries = []; 57 $entries = [];
58 $tagsCache = [];
58 59
59 foreach ($rules as $rule) { 60 foreach ($rules as $rule) {
60 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); 61 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
@@ -62,7 +63,12 @@ class RuleBasedTagger
62 63
63 foreach ($entries as $entry) { 64 foreach ($entries as $entry) {
64 foreach ($rule->getTags() as $label) { 65 foreach ($rule->getTags() as $label) {
65 $tag = $this->getTag($label); 66 // avoid new tag duplicate by manually caching them
67 if (!isset($tagsCache[$label])) {
68 $tagsCache[$label] = $this->getTag($label);
69 }
70
71 $tag = $tagsCache[$label];
66 72
67 $entry->addTag($tag); 73 $entry->addTag($tag);
68 } 74 }