From 68060f545a70da5d4d4fbb94592931239db6d261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Dec 2020 16:01:13 +0100 Subject: [PATCH] Added a query to parse only non-hashed URL Fixed #4864 --- .../Command/GenerateUrlHashesCommand.php | 2 +- .../CoreBundle/Repository/EntryRepository.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php index a0e9221e3..f870059bb 100644 --- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php +++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php @@ -59,7 +59,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); - $entries = $repo->findByUser($user->getId()); + $entries = $repo->findByEmptyHashedUrlAndUserId($user->getId()); $i = 1; foreach ($entries as $entry) { diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 62ff3d7ef..4222f313f 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -369,6 +369,20 @@ class EntryRepository extends EntityRepository ); } + /** + * Find all entries which have an empty value for hash. + * + * @return Entry|false + */ + public function findByEmptyHashedUrlAndUserId(int $userId) + { + return $this->createQueryBuilder('e') + ->where('e.hashedUrl = :empty')->setParameter('empty', '') + ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) + ->getQuery() + ->getResult(); + } + /** * Find an entry by its hashed url and its owner. * If it exists, return the entry otherwise return false.