mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 09:31:04 +00:00
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.
This commit is contained in:
parent
4d318f3755
commit
b4fcd60e7f
1 changed files with 7 additions and 1 deletions
|
@ -55,6 +55,7 @@ class RuleBasedTagger
|
|||
{
|
||||
$rules = $this->getRulesForUser($user);
|
||||
$entries = [];
|
||||
$tagsCache = [];
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
|
||||
|
@ -62,7 +63,12 @@ class RuleBasedTagger
|
|||
|
||||
foreach ($entries as $entry) {
|
||||
foreach ($rule->getTags() as $label) {
|
||||
$tag = $this->getTag($label);
|
||||
// avoid new tag duplicate by manually caching them
|
||||
if (!isset($tagsCache[$label])) {
|
||||
$tagsCache[$label] = $this->getTag($label);
|
||||
}
|
||||
|
||||
$tag = $tagsCache[$label];
|
||||
|
||||
$entry->addTag($tag);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue