Skip to content

Commit

Permalink
fix repository pattern to prevent saving contacts and imap/smtp serve…
Browse files Browse the repository at this point in the history
…rs during initialization
  • Loading branch information
kroky committed Apr 8, 2024
1 parent 0ae9f8f commit d7e7a3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ public static function init($name, $user_config) {
* @param int $id server id
* @return void
*/
public static function add($atts) {
public static function add($atts, $save = true) {
$atts['object'] = false;
$atts['connected'] = false;
return self::repo_add($atts);
return self::repo_add($atts, $save);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions modules/contacts/hm-contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Hm_Contact_Store {
public function init($user_config, $session) {
self::initRepo('contacts', $user_config, $session, $this->data, function($initial) {
foreach ($initial as $contact) {
$this->add_contact($contact);
$this->add_contact($contact, false);
}
});
}
Expand All @@ -43,9 +43,9 @@ public static function save() {
public function __construct() {
}

public function add_contact($data) {
public function add_contact($data, $save = true) {
$contact = new Hm_Contact($data);
self::add($contact);
self::add($contact, $save);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1536,11 +1536,10 @@ public function process() {
foreach (Hm_IMAP_List::getAll() as $id => $server) {
if ($this->session->loaded) {
if (array_key_exists('expiration', $server)) {
$updated = true;
$server['expiration'] = 1;
Hm_IMAP_List::edit($id, $server);
}
}
Hm_IMAP_List::edit($id, $server);
if (array_key_exists('default', $server) && $server['default']) {
$has_default = true;
}
Expand Down

0 comments on commit d7e7a3e

Please sign in to comment.