From: Jérôme Benoit Date: Sun, 1 Jul 2018 15:34:02 +0000 (+0200) Subject: Ensure we do not try to return an empty array row. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=19b09998f57d37c571830bed32c1090a424b91cb;p=Project_proches_de_moi-server.git Ensure we do not try to return an empty array row. Signed-off-by: Jérôme Benoit --- diff --git a/src/Controller/PersonController.php b/src/Controller/PersonController.php index 49c456d..b34bb53 100644 --- a/src/Controller/PersonController.php +++ b/src/Controller/PersonController.php @@ -179,7 +179,10 @@ class PersonController extends FOSRestController private function getLastLocalisation($em, $id) { $query = $em->createQuery("SELECT l1 FROM App\Entity\Localisation l1 WHERE l1.person = :person and l1.timestamp = (SELECT MAX(l2.timestamp) FROM App\Entity\Localisation l2 WHERE l2.person = l1.person)"); $query->setParameter('person', $id); - return $query->getResult()[0]; + $result = $query->getResult(); + if (!empty($result)) { + return $result[0]; + } } /**