Mostly when the tag doesn’t yet exist.
It was created each time it matche the rule… glups.
{
$rules = $this->getRulesForUser($user);
$entries = [];
+ $tagsCache = [];
foreach ($rules as $rule) {
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
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);
}