diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index fabb1963..45366623 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Wallabag\CoreBundle\Repository; | 3 | namespace Wallabag\CoreBundle\Repository; |
4 | 4 | ||
5 | use Doctrine\ORM\EntityRepository; | 5 | use Doctrine\ORM\EntityRepository; |
6 | use Doctrine\ORM\NoResultException; | ||
6 | use Doctrine\ORM\QueryBuilder; | 7 | use Doctrine\ORM\QueryBuilder; |
7 | use Pagerfanta\Adapter\DoctrineORMAdapter; | 8 | use Pagerfanta\Adapter\DoctrineORMAdapter; |
8 | use Pagerfanta\Pagerfanta; | 9 | use Pagerfanta\Pagerfanta; |
@@ -437,7 +438,7 @@ class EntryRepository extends EntityRepository | |||
437 | * @param int $userId | 438 | * @param int $userId |
438 | * @param string $type Can be unread, archive, starred, etc | 439 | * @param string $type Can be unread, archive, starred, etc |
439 | * | 440 | * |
440 | * @throws \Doctrine\ORM\NoResultException | 441 | * @throws NoResultException |
441 | * | 442 | * |
442 | * @return Entry | 443 | * @return Entry |
443 | */ | 444 | */ |
@@ -464,6 +465,10 @@ class EntryRepository extends EntityRepository | |||
464 | 465 | ||
465 | $ids = $qb->getQuery()->getArrayResult(); | 466 | $ids = $qb->getQuery()->getArrayResult(); |
466 | 467 | ||
468 | if (empty($ids)) { | ||
469 | throw new NoResultException(); | ||
470 | } | ||
471 | |||
467 | // random select one in the list | 472 | // random select one in the list |
468 | $randomId = $ids[mt_rand(0, \count($ids) - 1)]['id']; | 473 | $randomId = $ids[mt_rand(0, \count($ids) - 1)]['id']; |
469 | 474 | ||