From: Olivier Mehani Date: Fri, 3 May 2019 12:23:04 +0000 (+1000) Subject: Delegate findByUrlAndUserId to findByHashedUrlAndUserId X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=sidebyside;h=d5744bf0dfdbee4dbbe380d8a076d07b89fc76e6;hp=31e276fc1636b41b03b7c29127681de257c16b06;p=github%2Fwallabag%2Fwallabag.git Delegate findByUrlAndUserId to findByHashedUrlAndUserId Signed-off-by: Olivier Mehani --- diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 3990932e..960b682d 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -348,17 +348,9 @@ class EntryRepository extends EntityRepository */ public function findByUrlAndUserId($url, $userId) { - $res = $this->createQueryBuilder('e') - ->where('e.url = :url')->setParameter('url', urldecode($url)) - ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) - ->getQuery() - ->getResult(); - - if (\count($res)) { - return current($res); - } - - return false; + return $this->findByHashedUrlAndUserId( + hash('sha1', $url), // XXX: the hash logic would better be in a separate util to avoid duplication with GenerateUrlHashesCommand::generateHashedUrls + $userId); } /**