]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Merge pull request #1493 from wallabag/v2-pocket-import
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 5aa582f8d434a1c4638ca3127a41d9efe5501cfb..f11a77860450105624623e5eae91869fbac09849 100644 (file)
@@ -245,7 +245,7 @@ class Entry
     /**
      * Set isArchived.
      *
-     * @param string $isArchived
+     * @param bool $isArchived
      *
      * @return Entry
      */
@@ -259,7 +259,7 @@ class Entry
     /**
      * Get isArchived.
      *
-     * @return string
+     * @return bool
      */
     public function isArchived()
     {
@@ -276,7 +276,7 @@ class Entry
     /**
      * Set isStarred.
      *
-     * @param string $isStarred
+     * @param bool $isStarred
      *
      * @return Entry
      */
@@ -290,7 +290,7 @@ class Entry
     /**
      * Get isStarred.
      *
-     * @return string
+     * @return bool
      */
     public function isStarred()
     {
@@ -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->getLabel() === $tag->getLabel()) {
+                return;
+            }
+        }
+
         $this->tags[] = $tag;
         $tag->addEntry($this);
     }