return 404 for details when no bject is found in database

Fixes #2157.
This commit is contained in:
Sarah Hoffmann
2021-02-22 16:28:29 +01:00
parent 72b01148d2
commit 5b7483ada5
2 changed files with 10 additions and 5 deletions

View File

@@ -81,11 +81,16 @@ if ($sOsmType && $iOsmId > 0) {
exit; exit;
} }
} }
if ($sPlaceId === false) {
throw new Exception('No place with that OSM ID found.', 404);
}
} else {
if ($sPlaceId === false) {
userError('Required parameters missing. Need either osmtype/osmid or place_id.');
}
} }
if ($sPlaceId === false) userError('Please select a place id');
$iPlaceID = (int)$sPlaceId; $iPlaceID = (int)$sPlaceId;
if (CONST_Use_US_Tiger_Data) { if (CONST_Use_US_Tiger_Data) {
@@ -140,7 +145,7 @@ $sSQL .= " WHERE place_id = $iPlaceID";
$aPointDetails = $oDB->getRow($sSQL, null, 'Could not get details of place object.'); $aPointDetails = $oDB->getRow($sSQL, null, 'Could not get details of place object.');
if (!$aPointDetails) { if (!$aPointDetails) {
userError('Unknown place id.'); throw new Exception('No place with that place ID found.', 404);
} }
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber']; $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];

View File

@@ -44,7 +44,7 @@ Feature: Object details
Scenario Outline: Details via unknown OSM id Scenario Outline: Details via unknown OSM id
When sending details query for <object> When sending details query for <object>
Then a HTTP 400 is returned Then a HTTP 404 is returned
Examples: Examples:
| object | | object |