From d5744bf0dfdbee4dbbe380d8a076d07b89fc76e6 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Fri, 3 May 2019 22:23:04 +1000 Subject: [PATCH] Delegate findByUrlAndUserId to findByHashedUrlAndUserId Signed-off-by: Olivier Mehani --- .../CoreBundle/Repository/EntryRepository.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) 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); } /** -- 2.41.0