]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Avoid multiple tag creation
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 608ed2f0d4ababf41230640cfb45804b137cf687..2813c94420c8a55d9523c18e5f2b0f3715f7cb4f 100644 (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);
     }