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.