forked from hans/Nominatim
Guard against network failures in getDatabaseDate()
When updating use the date from the diff file instead as we are guaranteed to get this if the file has been successfully loaded.
This commit is contained in:
@@ -38,8 +38,13 @@ function getDatabaseDate(&$oDB)
|
||||
// Find the newest node in the DB
|
||||
$iLastOSMID = $oDB->getOne("select max(osm_id) from place where osm_type = 'N'");
|
||||
// Lookup the timestamp that node was created
|
||||
$sLastNodeURL = 'http://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID."/1";
|
||||
$sLastNodeURL = 'https://www.openstreetmap.org/api/0.6/node/'.$iLastOSMID."/1";
|
||||
$sLastNodeXML = file_get_contents($sLastNodeURL);
|
||||
|
||||
if ($sLastNodeXML === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
preg_match('#timestamp="(([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z)"#', $sLastNodeXML, $aLastNodeDate);
|
||||
|
||||
return $aLastNodeDate[1];
|
||||
|
||||
Reference in New Issue
Block a user