bobosch / ods_osm

TYPO3 Extension OpenStreetMap
10 stars 22 forks source link

Div::searchAddressNominatim might access not existing array entry "city" when saving tt_address #178

Closed sypets closed 6 months ago

sypets commented 6 months ago

PHP Warning: Undefined array key "city" in /var/www/site-uol11/htdocs/typo3conf/ext/ods_osm/Classes/Div.php line 365

Trying to save tt_address dataset (without latitude and longitude):

name=***
address=***
city=Jade-Jaderberg
zip=26349
region=Wesermarsch
country=Deutschland

code

364 if (($result[0]['address']['city'] ?? false) || ($result[0]['address']['village'] ?? false)) {
365     $address['city'] = $result[0]['address']['city'] ? (string)$result[0]['address']['city'] : (string)$result[0]['address']['village'];
366 }

https://github.com/bobosch/ods_osm/blob/master/Classes/Div.php#L372

debug: $result[0]['address']:

village='Jaderberg' Entry for city is missing. Looks like it might be better to use null coalesce ?? to access the values. (It is used in the if, but then it accesses the entries directly if city or village is set.

versions