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

Avoid multiple tag creation

When a new tag is created but not yet persisted, it can be duplicated.
It could happen when multiple rules match the content and at least 2 of them should attach same new tag.

Fix #1528
This commit is contained in:
Jeremy Benoist 2015-12-27 22:26:49 +01:00
parent 82899c0402
commit fc031e5706
3 changed files with 69 additions and 0 deletions

View file

@ -462,6 +462,14 @@ class Entry
return;
}
// check if tag already exist but has not yet be persisted
// it seems that the previous condition with `contains()` doesn't check that case
foreach ($this->tags as $existingTag) {
if ($existingTag->getUser() !== $tag->getUser() || $existingTag->getLabel() === $tag->getLabel()) {
return;
}
}
$this->tags[] = $tag;
$tag->addEntry($this);
}