From 9c8e0260035294ddc985f78b45efc0132cd6c4fe Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Wed, 30 Apr 2025 07:36:35 +0200 Subject: fix (WeatherStatus): Check if result is an array Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- apps/weather_status/lib/Service/WeatherStatusService.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/weather_status/lib/Service/WeatherStatusService.php b/apps/weather_status/lib/Service/WeatherStatusService.php index 04500cf66a5..c93010e7f58 100644 --- a/apps/weather_status/lib/Service/WeatherStatusService.php +++ b/apps/weather_status/lib/Service/WeatherStatusService.php @@ -257,12 +257,19 @@ class WeatherStatusService { ]; $url = 'https://nominatim.openstreetmap.org/search'; $results = $this->requestJSON($url, $params); - if ($results['error'] !== null) { - return $results; + + if (isset($results['error'])) { + return ['error' => (string)$results['error']]; } - if (count($results) > 0) { - return $results[0]; + + if (count($results) > 0 && is_array($results[0])) { + return [ + 'display_name' => (string)($results[0]['display_name'] ?? null), + 'lat' => (string)($results[0]['lat'] ?? null), + 'lon' => (string)($results[0]['lon'] ?? null), + ]; } + return ['error' => $this->l10n->t('No result.')]; } -- cgit v1.2.3