Skip to content

Commit

Permalink
Fix bug where installto.sh/update.sh scripts were removing some essen…
Browse files Browse the repository at this point in the history
…tial options from the config file (roundcube#9051)

Plus small code improvements
  • Loading branch information
alecpl committed Jul 8, 2023
1 parent ad9ffa8 commit 57b1611
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions bin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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));
}

Expand Down
14 changes: 5 additions & 9 deletions program/include/rcmail_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -460,20 +460,16 @@ 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']);
}
}
}

$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];
}
}

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/Rcmail/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 57b1611

Please sign in to comment.