* connect to db after successful setup so siteconfig doesn't fail
This commit is contained in:
Sarjuuk
2021-02-18 21:11:08 +01:00
parent f5701e7979
commit 43778b01e7
4 changed files with 10 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ class DB
$interface = DbSimple_Generic::connect(self::createConnectSyntax($options));
if (!$interface || $interface->error)
die('Failed to connect to database.');
die('Failed to connect to database on index #'.$idx.".\n");
$interface->setErrorHandler(['DB', 'errorHandler']);
$interface->query('SET NAMES ?', 'utf8mb4');

View File

@@ -26,7 +26,8 @@ function finish(bool $unlock = true) : void
function lockSite(bool $enable = true) : void
{
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "maintenance"', $enable ? 1 : 0);
if (DB::isConnectable(DB_AOWOW))
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "maintenance"', $enable ? 1 : 0);
}
CLISetup::init();

View File

@@ -120,7 +120,7 @@ function firstrun() : bool
$error = [];
$defPort = ini_get('mysqli.default_port');
foreach (['world', 'aowow', 'auth'] as $what)
foreach (['aowow', 'world', 'auth'] as $idx => $what)
{
if ($what == 'auth' && (empty($AoWoWconf['auth']) || empty($AoWoWconf['auth']['host'])))
continue;
@@ -130,7 +130,12 @@ function firstrun() : bool
[$AoWoWconf[$what]['host'], $port] = explode(':', $AoWoWconf[$what]['host']);
if ($link = @mysqli_connect($AoWoWconf[$what]['host'], $AoWoWconf[$what]['user'], $AoWoWconf[$what]['pass'], $AoWoWconf[$what]['db'], $port ?: $defPort))
{
mysqli_close($link);
// init proper access for further setup
DB::load($idx, $AoWoWconf[$what]);
}
else
$error[] = ' * '.$what.': '.'['.mysqli_connect_errno().'] '.mysqli_connect_error();
}

View File

@@ -16,7 +16,7 @@ function siteconfig()
$reqKeys = ['site_host', 'static_host'];
$updScripts = [];
if (!DB::isConnected(DB_AOWOW))
if (!DB::isConnectable(DB_AOWOW))
{
CLI::write();
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);