Skip to content

Commit

Permalink
Rework 5th step of installation, to fix some pointless message about …
Browse files Browse the repository at this point in the history
…Cache
  • Loading branch information
slawkens committed Jul 9, 2024
1 parent 10a7397 commit d948287
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 43 deletions.
85 changes: 42 additions & 43 deletions install/steps/5-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,56 @@
$configToSave['cache_engine'] = 'auto';
$configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true);

require BASE . 'install/includes/config.php';

if(!$error) {
require BASE . 'install/includes/database.php';
$content = '';
$saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content);
if ($saved) {
success($locale['step_database_config_saved']);
$_SESSION['saved'] = true;

$locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']);
success($locale['step_database_importing']);
require BASE . 'config.local.php';
require BASE . 'install/includes/config.php';

if(isset($database_error)) { // we failed connect to the database
error($database_error);
}
else {
if(!$db->hasTable('accounts')) {
$tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
error($tmp);
$error = true;
}

if(!$db->hasTable('players')) {
$tmp = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
error($tmp);
$error = true;
}
if (!$error) {
require BASE . 'install/includes/database.php';

if(!$db->hasTable('guilds')) {
$tmp = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
error($tmp);
$error = true;
}

if(!$error) {
$content = '';
$saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content);
if($saved) {
success($locale['step_database_config_saved']);
$_SESSION['saved'] = true;

$twig->display('install.installer.html.twig', array(
'url' => 'tools/5-database.php',
'message' => $locale['loading_spinner']
));
if (isset($database_error)) { // we failed connect to the database
error($database_error);
}
else {
$_SESSION['config_content'] = $content;
unset($_SESSION['saved']);

$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.php</b>', $locale['step_database_error_file']);
error($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>');
if (!$db->hasTable('accounts')) {
$tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
error($tmp);
$error = true;
}

if (!$db->hasTable('players')) {
$tmp = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
error($tmp);
$error = true;
}

if (!$db->hasTable('guilds')) {
$tmp = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
error($tmp);
$error = true;
}

if (!$error) {
$twig->display('install.installer.html.twig', array(
'url' => 'tools/5-database.php',
'message' => $locale['loading_spinner']
));
}
}
}
} else {
$_SESSION['config_content'] = $content;
unset($_SESSION['saved']);

$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.php</b>', $locale['step_database_error_file']);
error($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>');
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions install/tools/5-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
else {
// import schema
try {
$locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']);
success($locale['step_database_importing']);

$db->query(file_get_contents(BASE . 'install/includes/schema.sql'));

$locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']);
Expand Down
1 change: 1 addition & 0 deletions system/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
}

if(defined('MYAAC_INSTALL')) {
$error = $e->getMessage();
return; // installer will take care of this
}

Expand Down

0 comments on commit d948287

Please sign in to comment.