Merge pull request #4865 from wallabag/fix-4864

Added a query to parse only non-hashed URL
This commit is contained in:
Nicolas Lœuillet 2020-12-21 08:53:33 +01:00 committed by GitHub
commit 863dd6ed07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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');
$repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
$entries = $repo->findByUser($user->getId());
$entries = $repo->findByEmptyHashedUrlAndUserId($user->getId());
$i = 1;
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.
* If it exists, return the entry otherwise return false.