Added a query to parse only non-hashed URL

Fixed #4864
This commit is contained in:
Nicolas Lœuillet 2020-12-18 16:01:13 +01:00
parent ad621f198f
commit 68060f545a
2 changed files with 15 additions and 1 deletions

View file

@ -59,7 +59,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); $em = $this->getContainer()->get('doctrine.orm.entity_manager');
$repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); $repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
$entries = $repo->findByUser($user->getId()); $entries = $repo->findByEmptyHashedUrlAndUserId($user->getId());
$i = 1; $i = 1;
foreach ($entries as $entry) { foreach ($entries as $entry) {

View file

@ -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. * Find an entry by its hashed url and its owner.
* If it exists, return the entry otherwise return false. * If it exists, return the entry otherwise return false.