]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Backport all icomoon from v1
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 5aa582f8d434a1c4638ca3127a41d9efe5501cfb..2813c94420c8a55d9523c18e5f2b0f3715f7cb4f 100644 (file)
@@ -458,6 +458,18 @@ class Entry
      */
     public function addTag(Tag $tag)
     {
+        if ($this->tags->contains($tag)) {
+            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);
     }