mirror of
https://github.com/nextcloud/server.git
synced 2026-02-28 04:20:37 -05:00
Merge pull request #52551 from nextcloud/checkResultArray
fix(WeatherStatus): Check if result is an array
This commit is contained in:
commit
a67720552e
1 changed files with 11 additions and 4 deletions
|
|
@ -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.')];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue