From: Sarah Hoffmann Date: Mon, 17 May 2021 14:36:32 +0000 (+0200) Subject: always use object type for details keywords X-Git-Tag: v4.0.0~80^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/fef1bbb1a77477867e9f20da4c473d880675e0e7?ds=inline;hp=-c always use object type for details keywords When name and address is empty, the keywords field in the response of the details API would be an array because that is what PHP's json_encode defaults to with empty array(). This default can only be changed globally per json_encode call and that might cause unintended colleteral damage. Work around the issue by making name and address an empty array instead of keywords. Fixes #2329. --- fef1bbb1a77477867e9f20da4c473d880675e0e7 diff --git a/lib-php/template/details-json.php b/lib-php/template/details-json.php index 0449dbb9..a813b9a6 100644 --- a/lib-php/template/details-json.php +++ b/lib-php/template/details-json.php @@ -81,10 +81,14 @@ if ($bIncludeKeywords) { if ($aPlaceSearchNameKeywords) { $aPlaceDetails['keywords']['name'] = array_map($funcMapKeyword, $aPlaceSearchNameKeywords); + } else { + $aPlaceDetails['keywords']['name'] = array(); } if ($aPlaceSearchAddressKeywords) { $aPlaceDetails['keywords']['address'] = array_map($funcMapKeyword, $aPlaceSearchAddressKeywords); + } else { + $aPlaceDetails['keywords']['address'] = array(); } }