Fix when config.local.php cannot be saved

This commit is contained in:
slawkens
2025-09-09 17:49:05 +02:00
parent 3f24f961b1
commit 4eab805d26

View File

@@ -42,45 +42,44 @@ if(!$error) {
$configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true); $configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true);
$configToSave['database_auto_migrate'] = true; $configToSave['database_auto_migrate'] = true;
if(!$error) { $content = '';
$content = ''; $saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content);
$saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content); if ($saved || file_exists(BASE . 'config.local.php')) {
if ($saved) { success($locale['step_database_config_saved']);
success($locale['step_database_config_saved']); $_SESSION['saved'] = true;
$_SESSION['saved'] = true;
require BASE . 'config.local.php'; require BASE . 'config.local.php';
require BASE . 'install/includes/config.php'; require BASE . 'install/includes/config.php';
if (!$error) { if (!$error) {
require BASE . 'install/includes/database.php'; require BASE . 'install/includes/database.php';
if (isset($database_error)) { // we failed connect to the database if (isset($database_error)) { // we failed connect to the database
error($database_error); error($database_error);
}
else {
if (!$db->hasTable('accounts')) {
$tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
error($tmp);
$error = true;
} }
else {
if (!$db->hasTable('accounts')) {
$tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
error($tmp);
$error = true;
}
if (!$error) { if (!$error) {
$twig->display('install.installer.html.twig', array( $twig->display('install.installer.html.twig', array(
'url' => 'tools/5-database.php', 'url' => 'tools/5-database.php',
'message' => $locale['loading_spinner'] '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>');
} }
} else {
$error = true;
$_SESSION['config_content'] = $content;
unset($_SESSION['saved']);
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
error($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>');
} }
} }
?> ?>