Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refact #1099 to make tests work #1101

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public function filter_servers() {
foreach ($this->config as $key => $vals) {
if (in_array($key, $excluded, true)) {
foreach ($vals as $index => $server) {
if (!array_key_exists('server', $server)) {
if (!empty($server['default'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns the error we wanted to fix. The goal of removing this code was to allow you to have the same unique identifier for the default server each time you reconnect. This resulted in losing the configured folders. With this we will have the same problem.

$removed[$key][$index] = $server;
unset($this->config[$key][$index]);
} elseif (!array_key_exists('server', $server)) {
$removed[$key][$index] = $server;
unset($this->config[$key][$index]);
} else {
Expand Down
18 changes: 10 additions & 8 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,7 @@ class Hm_Handler_load_imap_servers_from_config extends Hm_Handler_Module {
public function process() {
Hm_IMAP_List::init($this->user_config, $this->session);
$default_server_id = false;
$has_default = false;
foreach (Hm_IMAP_List::getAll() as $id => $server) {
if ($this->session->loaded) {
if (array_key_exists('expiration', $server)) {
Expand All @@ -1541,8 +1542,9 @@ public function process() {
}
}
if (array_key_exists('default', $server) && $server['default']) {
$default_server_id = $id;
$has_default = true;
}
$default_server_id = $id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why default_server_Id is every ID in the imap list? Shouldn't it be only the one marked as default or maybe the first one?

}
$auth_server = $this->session->get('imap_auth_server_settings', array());
if (!empty($auth_server)) {
Expand All @@ -1554,7 +1556,7 @@ public function process() {
}
$imap_details = array(
'name' => $name,
'default' => true,
'default' => $has_default,
'server' => $auth_server['server'],
'port' => $auth_server['port'],
'tls' => $auth_server['tls'],
Expand All @@ -1564,12 +1566,12 @@ public function process() {
if (! empty($auth_server['sieve_config_host'])) {
$imap_details['sieve_config_host'] = $auth_server['sieve_config_host'];
}
}
if (!$default_server_id) {
Hm_IMAP_List::add($imap_details);
} else {
// Perhaps something as changed
Hm_IMAP_List::edit($default_server_id, $imap_details);
if (!$default_server_id) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm_IMAP_List::add($imap_details);
} else {
// Perhaps something as changed
Hm_IMAP_List::edit($default_server_id, $imap_details);
}
}
}
}
Expand Down