diff --git a/CHANGELOG.md b/CHANGELOG.md index cb7d109eb22..bc9f2275c21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Password: Add ldap_samba_ad driver (#8525) - Password: Allow LDAP access using LDAP URI and SASL binding (#8402) - Fix potential HTTP protocol version mismatch (#8982) +- Fix bug where installto.sh/update.sh scripts were removing some essential options from the config file (#9051) ## Release 1.6.2 diff --git a/bin/update.sh b/bin/update.sh index 8db7d8b92cf..5728658b960 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -88,7 +88,7 @@ if ($RCI->configured) { if (!empty($opts['accept']) || strtolower($input) == 'y') { $error = $written = false; - echo ". backing up the current config file(s)...\n"; + echo "- backing up the current config file(s)...\n"; foreach (['config', 'main', 'db'] as $file) { if (file_exists(RCMAIL_CONFIG_DIR . '/' . $file . '.inc.php')) { @@ -100,7 +100,7 @@ if ($RCI->configured) { if (!$error) { $RCI->merge_config(); - echo ". writing " . RCMAIL_CONFIG_DIR . "/config.inc.php...\n"; + echo "- writing " . RCMAIL_CONFIG_DIR . "/config.inc.php...\n"; $written = $RCI->save_configfile($RCI->create_config(false)); } diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php index 5adcfe3fe93..70877dd5ada 100644 --- a/program/include/rcmail_install.php +++ b/program/include/rcmail_install.php @@ -435,10 +435,10 @@ public function merge_config() else { $this->config[$replacement] = $current[$prop]; } - } - unset($current[$prop]); - unset($current[$replacement]); + unset($current[$prop]); + unset($current[$replacement]); + } } // Merge old *_port options into the new *_host options, where possible @@ -460,9 +460,9 @@ public function merge_config() } // add all ldap_public sources having global_search enabled to autocomplete_addressbooks - if (is_array($current['ldap_public'])) { + if (!empty($current['ldap_public']) && is_array($current['ldap_public'])) { foreach ($current['ldap_public'] as $key => $ldap_public) { - if ($ldap_public['global_search']) { + if (!empty($ldap_public['global_search'])) { $this->config['autocomplete_addressbooks'][] = $key; unset($current['ldap_public'][$key]['global_search']); } @@ -470,10 +470,6 @@ public function merge_config() } $this->config = array_merge($this->config, $current); - - foreach (array_keys((array) $current['ldap_public']) as $key) { - $this->config['ldap_public'][$key] = $current['ldap_public'][$key]; - } } /** diff --git a/tests/Rcmail/Install.php b/tests/Rcmail/Install.php index fe3ca7cac98..691415104bc 100644 --- a/tests/Rcmail/Install.php +++ b/tests/Rcmail/Install.php @@ -116,4 +116,26 @@ function test_list_plugins() $this->assertSame($acl, $result[0]); } + + /** + * Test merge_config() method + */ + function test_merge_config() + { + $config = [ + 'imap_host' => 'ssl://test:993', + 'smtp_host' => 'ssl://test:465', + ]; + + $install = rcmail_install::get_instance(); + $install->configured = true; + $install->config = $config; + + $install->merge_config(); + + $this->assertSame($config['imap_host'], $install->config['imap_host']); + $this->assertSame($config['smtp_host'], $install->config['smtp_host']); + + $this->markTestIncomplete(); // TODO: More tests + } }