diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-12-27 22:26:49 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-12-28 13:20:48 +0100 |
commit | fc031e5706acf89ff21f22ca8004ddc7f9b43089 (patch) | |
tree | 845fd4f69308dc11ca6c54cc9ed4be62cb4f471c /src/Wallabag/CoreBundle/Entity | |
parent | 82899c040258896bff540080602e93aa49a71ae8 (diff) | |
download | wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.gz wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.tar.zst wallabag-fc031e5706acf89ff21f22ca8004ddc7f9b43089.zip |
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
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 608ed2f0..2813c944 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -462,6 +462,14 @@ class Entry | |||
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | 464 | ||
465 | // check if tag already exist but has not yet be persisted | ||
466 | // it seems that the previous condition with `contains()` doesn't check that case | ||
467 | foreach ($this->tags as $existingTag) { | ||
468 | if ($existingTag->getUser() !== $tag->getUser() || $existingTag->getLabel() === $tag->getLabel()) { | ||
469 | return; | ||
470 | } | ||
471 | } | ||
472 | |||
465 | $this->tags[] = $tag; | 473 | $this->tags[] = $tag; |
466 | $tag->addEntry($this); | 474 | $tag->addEntry($this); |
467 | } | 475 | } |