implicitly connect to database during setup

Make access to the DB object a function, so that the connection
can be opened implicitly when the object is accessed for the first
time. This way we no longer need to check beforehand if a specific
function of the setup needs DB access or not.

Also move the check for the module to the relevant sub step.
This commit is contained in:
Sarah Hoffmann
2020-07-26 11:56:00 +02:00
parent 840c692d5b
commit 8cd9550295
2 changed files with 58 additions and 51 deletions

View File

@@ -77,18 +77,11 @@ if ($aCMDResult['create-db'] || $aCMDResult['all']) {
$oSetup->createDB();
}
if (!$aCMDResult['setup-website']) {
$oSetup->connect();
// Try accessing the C module, so we know early if something is wrong
checkModulePresence(); // raises exception on failure
}
if ($aCMDResult['setup-db'] || $aCMDResult['all']) {
$bDidSomething = true;
$oSetup->setupDB();
}
if ($aCMDResult['import-data'] || $aCMDResult['all']) {
$bDidSomething = true;
$oSetup->importData($aCMDResult['osm-file']);