mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Setup/DB
* connect to db after successful setup so siteconfig doesn't fail
This commit is contained in:
@@ -31,7 +31,7 @@ class DB
|
|||||||
$interface = DbSimple_Generic::connect(self::createConnectSyntax($options));
|
$interface = DbSimple_Generic::connect(self::createConnectSyntax($options));
|
||||||
|
|
||||||
if (!$interface || $interface->error)
|
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->setErrorHandler(['DB', 'errorHandler']);
|
||||||
$interface->query('SET NAMES ?', 'utf8mb4');
|
$interface->query('SET NAMES ?', 'utf8mb4');
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ function finish(bool $unlock = true) : void
|
|||||||
|
|
||||||
function lockSite(bool $enable = 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();
|
CLISetup::init();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ function firstrun() : bool
|
|||||||
$error = [];
|
$error = [];
|
||||||
$defPort = ini_get('mysqli.default_port');
|
$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'])))
|
if ($what == 'auth' && (empty($AoWoWconf['auth']) || empty($AoWoWconf['auth']['host'])))
|
||||||
continue;
|
continue;
|
||||||
@@ -130,7 +130,12 @@ function firstrun() : bool
|
|||||||
[$AoWoWconf[$what]['host'], $port] = explode(':', $AoWoWconf[$what]['host']);
|
[$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))
|
if ($link = @mysqli_connect($AoWoWconf[$what]['host'], $AoWoWconf[$what]['user'], $AoWoWconf[$what]['pass'], $AoWoWconf[$what]['db'], $port ?: $defPort))
|
||||||
|
{
|
||||||
mysqli_close($link);
|
mysqli_close($link);
|
||||||
|
|
||||||
|
// init proper access for further setup
|
||||||
|
DB::load($idx, $AoWoWconf[$what]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$error[] = ' * '.$what.': '.'['.mysqli_connect_errno().'] '.mysqli_connect_error();
|
$error[] = ' * '.$what.': '.'['.mysqli_connect_errno().'] '.mysqli_connect_error();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function siteconfig()
|
|||||||
$reqKeys = ['site_host', 'static_host'];
|
$reqKeys = ['site_host', 'static_host'];
|
||||||
$updScripts = [];
|
$updScripts = [];
|
||||||
|
|
||||||
if (!DB::isConnected(DB_AOWOW))
|
if (!DB::isConnectable(DB_AOWOW))
|
||||||
{
|
{
|
||||||
CLI::write();
|
CLI::write();
|
||||||
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);
|
CLI::write("database not yet set up!\n Please use --dbconfig for setup", CLI::LOG_WARN);
|
||||||
|
|||||||
Reference in New Issue
Block a user