forked from wallabag/wallabag
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:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user