mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-24 13:31:37 +03:00
return a 500 on database error
This commit is contained in:
parent
57ef20cc7c
commit
4d7e0d97b2
25
lib/lib.php
25
lib/lib.php
@ -1,5 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
function failInternalError($sError, $sSQL = false, $vDumpVar = false)
|
||||||
|
{
|
||||||
|
header('HTTP/1.0 500 Internal Server Error');
|
||||||
|
header('Content-type: text/html; charset=utf-8');
|
||||||
|
echo "<html><body><h1>Internal Server Error</h1>";
|
||||||
|
echo '<p>Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.</p>';
|
||||||
|
echo "<p><b>Details:</b> ".$sError,"</p>";
|
||||||
|
echo '<p>Feel free to report the bug in the <a href="http://trac.openstreetmap.org">OSM bug database</a>. Please include the error message above an the URL you used.</p>';
|
||||||
|
if (CONST_Debug)
|
||||||
|
{
|
||||||
|
echo "<hr><h2>Debugging Information</h2><br>";
|
||||||
|
if ($sSQL) {
|
||||||
|
echo "<h3>SQL query</h3><code>".$sSQL."</code>";
|
||||||
|
}
|
||||||
|
if ($vDumpVar) {
|
||||||
|
echo "<h3>Result</h3> <code>";
|
||||||
|
var_dump($vDumpVar);
|
||||||
|
echo "</code>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "\n</body></html>\n";
|
||||||
|
exit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function fail($sError, $sUserError = false)
|
function fail($sError, $sUserError = false)
|
||||||
{
|
{
|
||||||
if (!$sUserError) $sUserError = $sError;
|
if (!$sUserError) $sUserError = $sError;
|
||||||
|
@ -48,11 +48,11 @@
|
|||||||
$sSQL .= " ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea,ST_GeometryType(geometry) as geotype, ST_Y(ST_Centroid(geometry)) as lat,ST_X(ST_Centroid(geometry)) as lon ";
|
$sSQL .= " ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') as isarea,ST_GeometryType(geometry) as geotype, ST_Y(ST_Centroid(geometry)) as lat,ST_X(ST_Centroid(geometry)) as lon ";
|
||||||
$sSQL .= " from placex where place_id = $iPlaceID";
|
$sSQL .= " from placex where place_id = $iPlaceID";
|
||||||
$aPointDetails = $oDB->getRow($sSQL);
|
$aPointDetails = $oDB->getRow($sSQL);
|
||||||
IF (PEAR::IsError($aPointDetails))
|
if (PEAR::IsError($aPointDetails))
|
||||||
{
|
{
|
||||||
var_dump($aPointDetails);
|
failInternalError("Could not get details of place object.", $sSQL, $aPointDetails);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];
|
||||||
$fLon = $aPointDetails['lon'];
|
$fLon = $aPointDetails['lon'];
|
||||||
$fLat = $aPointDetails['lat'];
|
$fLat = $aPointDetails['lat'];
|
||||||
@ -77,8 +77,7 @@
|
|||||||
$aPointPolygon = $oDB->getRow($sSQL);
|
$aPointPolygon = $oDB->getRow($sSQL);
|
||||||
IF (PEAR::IsError($aPointPolygon))
|
IF (PEAR::IsError($aPointPolygon))
|
||||||
{
|
{
|
||||||
var_dump($aPointPolygon);
|
failInternalError("Could not get bounding box of place object.", $sSQL, $aPointPolygon);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#',$aPointPolygon['outlinestring'],$aMatch))
|
if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#',$aPointPolygon['outlinestring'],$aMatch))
|
||||||
{
|
{
|
||||||
|
@ -105,8 +105,7 @@
|
|||||||
$iPlaceID = $aPlace['place_id'];
|
$iPlaceID = $aPlace['place_id'];
|
||||||
if (PEAR::IsError($iPlaceID))
|
if (PEAR::IsError($iPlaceID))
|
||||||
{
|
{
|
||||||
var_Dump($sSQL, $iPlaceID);
|
failInternalError("Could not determine closest place.", $sSQL, $iPlaceID);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +117,7 @@
|
|||||||
$iPlaceID = $oDB->getOne($sSQL);
|
$iPlaceID = $oDB->getOne($sSQL);
|
||||||
if (PEAR::IsError($iPlaceID))
|
if (PEAR::IsError($iPlaceID))
|
||||||
{
|
{
|
||||||
var_Dump($sSQL, $iPlaceID);
|
failInternalError("Could not get parent for place.", $sSQL, $iPlaceID);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28)
|
if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28)
|
||||||
@ -129,8 +127,7 @@
|
|||||||
$iPlaceID = $oDB->getOne($sSQL);
|
$iPlaceID = $oDB->getOne($sSQL);
|
||||||
if (PEAR::IsError($iPlaceID))
|
if (PEAR::IsError($iPlaceID))
|
||||||
{
|
{
|
||||||
var_Dump($sSQL, $iPlaceID);
|
failInternalError("Could not get larger parent for place.", $sSQL, $iPlaceID);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$iPlaceID)
|
if (!$iPlaceID)
|
||||||
|
@ -163,8 +163,7 @@
|
|||||||
$sViewboxSmallSQL = $oDB->getOne($sSQL);
|
$sViewboxSmallSQL = $oDB->getOne($sSQL);
|
||||||
if (PEAR::isError($sViewboxSmallSQL))
|
if (PEAR::isError($sViewboxSmallSQL))
|
||||||
{
|
{
|
||||||
var_dump($sViewboxSmallSQL);
|
failInternalError("Could not get small viewbox.", $sSQL, $sViewboxSmallSQL);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$sViewboxSmallSQL = "'".$sViewboxSmallSQL."'::geometry";
|
$sViewboxSmallSQL = "'".$sViewboxSmallSQL."'::geometry";
|
||||||
|
|
||||||
@ -172,8 +171,7 @@
|
|||||||
$sViewboxLargeSQL = $oDB->getOne($sSQL);
|
$sViewboxLargeSQL = $oDB->getOne($sSQL);
|
||||||
if (PEAR::isError($sViewboxLargeSQL))
|
if (PEAR::isError($sViewboxLargeSQL))
|
||||||
{
|
{
|
||||||
var_dump($sViewboxLargeSQL);
|
failInternalError("Could not get large viewbox.", $sSQL, $sViewboxLargeSQL);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$sViewboxLargeSQL = "'".$sViewboxLargeSQL."'::geometry";
|
$sViewboxLargeSQL = "'".$sViewboxLargeSQL."'::geometry";
|
||||||
}
|
}
|
||||||
@ -324,8 +322,7 @@
|
|||||||
$aDatabaseWords = array();
|
$aDatabaseWords = array();
|
||||||
if (PEAR::IsError($aDatabaseWords))
|
if (PEAR::IsError($aDatabaseWords))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aDatabaseWords);
|
failInternalError("Could not get word tokens.", $sSQL, $aDatabaseWords);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$aPossibleMainWordIDs = array();
|
$aPossibleMainWordIDs = array();
|
||||||
foreach($aDatabaseWords as $aToken)
|
foreach($aDatabaseWords as $aToken)
|
||||||
@ -789,8 +786,7 @@
|
|||||||
$aViewBoxPlaceIDs = $oDB->getAll($sSQL);
|
$aViewBoxPlaceIDs = $oDB->getAll($sSQL);
|
||||||
if (PEAR::IsError($aViewBoxPlaceIDs))
|
if (PEAR::IsError($aViewBoxPlaceIDs))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aViewBoxPlaceIDs);
|
failInternalError("Could not get places for search terms.", $sSQL, $aViewBoxPlaceIDs);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
//var_dump($aViewBoxPlaceIDs);
|
//var_dump($aViewBoxPlaceIDs);
|
||||||
// Did we have an viewbox matches?
|
// Did we have an viewbox matches?
|
||||||
@ -971,8 +967,7 @@
|
|||||||
|
|
||||||
if (PEAR::IsError($aPlaceIDs))
|
if (PEAR::IsError($aPlaceIDs))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aPlaceIDs);
|
failInternalError("Could not get place IDs from tokens." ,$sSQL, $aPlaceIDs);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONST_Debug) var_Dump($aPlaceIDs);
|
if (CONST_Debug) var_Dump($aPlaceIDs);
|
||||||
@ -1048,8 +1043,7 @@
|
|||||||
|
|
||||||
if (PEAR::IsError($aSearchResults))
|
if (PEAR::IsError($aSearchResults))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aSearchResults);
|
failInternalError("Could not get details for place.", $sSQL, $aSearchResults);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end if ($sQuery)
|
} // end if ($sQuery)
|
||||||
@ -1117,8 +1111,7 @@
|
|||||||
|
|
||||||
if (PEAR::IsError($aSearchResults))
|
if (PEAR::IsError($aSearchResults))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aSearchResults);
|
failInternalError("Could not get details for place (near).", $sSQL, $aSearchResults);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1149,8 +1142,7 @@
|
|||||||
$aPointPolygon = $oDB->getRow($sSQL);
|
$aPointPolygon = $oDB->getRow($sSQL);
|
||||||
if (PEAR::IsError($aPointPolygon))
|
if (PEAR::IsError($aPointPolygon))
|
||||||
{
|
{
|
||||||
var_dump($sSQL, $aPointPolygon);
|
failInternalError("Could not get outline.", $sSQL, $aPointPolygon);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
if ($aPointPolygon['place_id'])
|
if ($aPointPolygon['place_id'])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user