diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-04-30 07:36:35 +0200 |
---|---|---|
committer | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-04-30 08:01:35 +0200 |
commit | 9c8e0260035294ddc985f78b45efc0132cd6c4fe (patch) | |
tree | 33a48e98ca9b7323f9d68c732f0e650c450d50cd | |
parent | 88aa80e8478903a3f037186b7635ad1869037226 (diff) | |
download | nextcloud-server-checkResultArray.tar.gz nextcloud-server-checkResultArray.zip |
fix (WeatherStatus): Check if result is an arraycheckResultArray
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r-- | apps/weather_status/lib/Service/WeatherStatusService.php | 15 |
1 files 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.')]; } |