From c83833c45d2903dbf8da04cf49e00167d00beeb5 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 18 Jan 2017 01:36:21 +0300 Subject: [PATCH] Incorrect query build fix. --- .../Command/UpdateSubscriptionsCommand.php | 8 +++++++- .../Bundle/PointToolsBundle/Repository/UserRepository.php | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php index e79dd44..d0d6038 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php @@ -234,7 +234,13 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand $usersForUpdate = $this->userRepo->findBy(['removed' => false]); } else { /** @var User $serviceUser */ - $serviceUser = $this->userRepo->findActiveUserWithSubscribers($appUserId); + try { + $serviceUser = $this->userRepo->findActiveUserWithSubscribers($appUserId); + } catch (\Exception $e) { + $this->logger->error('Error while getting active user with subscribers', ['app_user_id' => $appUserId]); + + throw $e; + } if (!$serviceUser) { $this->logger->critical('Service user not found or marked as removed'); diff --git a/src/Skobkin/Bundle/PointToolsBundle/Repository/UserRepository.php b/src/Skobkin/Bundle/PointToolsBundle/Repository/UserRepository.php index 9161d1d..9476ed1 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Repository/UserRepository.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Repository/UserRepository.php @@ -22,9 +22,9 @@ class UserRepository extends EntityRepository ->select(['u', 's', 'us']) ->innerJoin('u.subscribers', 's') ->innerJoin('s.subscriber', 'us') - ->where('u.id = :id') - ->where('u.removed = FALSE') - ->setParameter('id', $id) + ->where('u.id = :user_id') + ->andWhere('u.removed = FALSE') + ->setParameter('user_id', $id) ->getQuery()->getOneOrNullResult() ; }