mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 10:27:57 +00:00
checkModulePresence now raises exception instead of its callers
This commit is contained in:
@@ -229,12 +229,6 @@ class DB
|
||||
return 'ARRAY['.join(',', $a).']';
|
||||
}
|
||||
|
||||
public function getLastError()
|
||||
{
|
||||
// https://secure.php.net/manual/en/pdo.errorinfo.php
|
||||
return $this->connection->errorInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a table exists in the database. Returns true if it does.
|
||||
*
|
||||
|
||||
@@ -144,9 +144,7 @@ class SetupFunctions
|
||||
}
|
||||
|
||||
// Try accessing the C module, so we know early if something is wrong
|
||||
if (!checkModulePresence()) {
|
||||
fail('error loading nominatim.so module');
|
||||
}
|
||||
checkModulePresence(); // raises exception on failure
|
||||
|
||||
if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
|
||||
echo 'Error: you need to download the country_osm_grid first:';
|
||||
@@ -227,11 +225,9 @@ class SetupFunctions
|
||||
{
|
||||
info('Create Functions');
|
||||
|
||||
// Try accessing the C module, so we know eif something is wrong
|
||||
// update.php calls this function
|
||||
if (!checkModulePresence()) {
|
||||
fail('error loading nominatim.so module');
|
||||
}
|
||||
// Try accessing the C module, so we know early if something is wrong
|
||||
checkModulePresence(); // raises exception on failure
|
||||
|
||||
$this->createSqlFunctions();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ function checkInFile($sOSMFile)
|
||||
|
||||
function checkModulePresence()
|
||||
{
|
||||
// Try accessing the C module, so we know early if something is wrong
|
||||
// and can simply error out.
|
||||
// Try accessing the C module, so we know early if something is wrong.
|
||||
// Raises Nominatim\DatabaseError on failure
|
||||
|
||||
$sModulePath = CONST_Database_Module_Path;
|
||||
$sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
|
||||
$sSQL .= $sModulePath . "/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
|
||||
@@ -26,15 +27,5 @@ function checkModulePresence()
|
||||
|
||||
$oDB = new \Nominatim\DB();
|
||||
$oDB->connect();
|
||||
|
||||
$bResult = true;
|
||||
try {
|
||||
$oDB->exec($sSQL);
|
||||
} catch (\Nominatim\DatabaseError $e) {
|
||||
echo "\nERROR: Failed to load nominatim module. Reason:\n";
|
||||
echo $oDB->getLastError()[2] . "\n\n";
|
||||
$bResult = false;
|
||||
}
|
||||
|
||||
return $bResult;
|
||||
$oDB->exec($sSQL, null, 'Database server failed to load '.$sModulePath.'/nominatim.so module');
|
||||
}
|
||||
|
||||
@@ -84,9 +84,7 @@ if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
|
||||
}
|
||||
|
||||
// Try accessing the C module, so we know early if something is wrong
|
||||
if (!checkModulePresence()) {
|
||||
fail('error loading nominatim.so module');
|
||||
}
|
||||
checkModulePresence(); // raises exception on failure
|
||||
|
||||
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
|
||||
$bDidSomething = true;
|
||||
|
||||
Reference in New Issue
Block a user