mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Preserve config.local.php on settings save
Will be helpful when migration from 0.8
This commit is contained in:
parent
d0590d2747
commit
c3c1a6b2a6
@ -129,6 +129,9 @@ class Settings implements ArrayAccess
|
||||
if (is_bool($value)) {
|
||||
$settingsDb[$key] = $value ? 'true' : 'false';
|
||||
}
|
||||
elseif (is_array($value)) {
|
||||
$settingsDb[$key] = $value;
|
||||
}
|
||||
else {
|
||||
$settingsDb[$key] = (string)$value;
|
||||
}
|
||||
@ -530,8 +533,11 @@ class Settings implements ArrayAccess
|
||||
|
||||
public static function saveConfig($config, $filename, &$content = '')
|
||||
{
|
||||
$content = "<?php" . PHP_EOL .
|
||||
"\$config['installed'] = true;" . PHP_EOL;
|
||||
$content = "<?php" . PHP_EOL;
|
||||
|
||||
unset($config['installed']);
|
||||
|
||||
$content .= "\$config['installed'] = true;" . PHP_EOL;
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
$content .= "\$config['$key'] = ";
|
||||
|
@ -1588,7 +1588,13 @@ Sent by MyAAC,<br/>
|
||||
'beforeSave' => function(&$settings, &$values) {
|
||||
global $config;
|
||||
|
||||
$configToSave = [];
|
||||
$configOriginal = $config;
|
||||
unset($config);
|
||||
|
||||
$config = [];
|
||||
require BASE . 'config.local.php';
|
||||
|
||||
$configToSave = $config;
|
||||
|
||||
$server_path = '';
|
||||
$database = [];
|
||||
@ -1625,7 +1631,7 @@ Sent by MyAAC,<br/>
|
||||
// if fail - revert the setting and inform the user
|
||||
if (!file_exists($server_path . 'config.lua')) {
|
||||
error('Server Path is invalid - cannot find config.lua in the directory. Setting have been reverted.');
|
||||
$configToSave['server_path'] = $config['server_path'];
|
||||
$configToSave['server_path'] = $configOriginal['server_path'];
|
||||
}
|
||||
|
||||
// test database connection
|
||||
@ -1633,7 +1639,7 @@ Sent by MyAAC,<br/>
|
||||
if ($database['database_overwrite'] && !Settings::testDatabaseConnection($database)) {
|
||||
foreach ($database as $key => $value) {
|
||||
if (!in_array($key, ['database_log', 'database_persistent'])) { // ignore these two
|
||||
$configToSave[$key] = $config[$key];
|
||||
$configToSave[$key] = $configOriginal[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user