]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Change the way to check for an existing entry
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index 502e9da05c0ee459dbe475630ff36bbdafeea7d1..b8e22eb833a4bea43150eb2c660cac900a4207ff 100644 (file)
@@ -226,18 +226,26 @@ class EntryRepository extends EntityRepository
 
     /**
      * Find an entry by its url and its owner.
+     * If it exists, return the entry otherwise return false.
      *
      * @param $url
      * @param $userId
      *
-     * @return array
+     * @return array|bool
      */
-    public function findOneByUrlAndUserId($url, $userId)
+    public function existByUrlAndUserId($url, $userId)
     {
-        return $this->createQueryBuilder('e')
+        $res = $this->createQueryBuilder('e')
+            ->select('e.id, e.createdAt')
             ->where('e.url = :url')->setParameter('url', $url)
             ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
             ->getQuery()
             ->getResult();
+
+        if (count($res) > 1) {
+            return next($res);
+        }
+
+        return false;
     }
 }