From 2f88320d4ff68e6454ba1a07cf8cc7c05e59f1db Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:47:14 +0530 Subject: [PATCH] Add null check --- app/controllers/shared/api.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index cbd481824e..512e8b38ff 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -637,9 +637,8 @@ App::init() $denylist = App::getEnv('_APP_COUNTRIES_DENYLIST', ''); if (!empty($denylist)) { $countries = explode(',', $denylist); - $record = $geodb->get($request->getIP()); - $country = $record['country']['iso_code']; - $countryName = $record['country']['names']['en']; + $record = $geodb->get($request->getIP()) ?? []; + $country = $record['country']['iso_code'] ?? ''; if (in_array($country, $countries)) { throw new Exception(Exception::GENERAL_REGION_ACCESS_DENIED); }