diff --git a/library/Icinga/User/Preferences/Store/DbStore.php b/library/Icinga/User/Preferences/Store/DbStore.php index 54d1f9380..728637a35 100644 --- a/library/Icinga/User/Preferences/Store/DbStore.php +++ b/library/Icinga/User/Preferences/Store/DbStore.php @@ -107,14 +107,10 @@ class DbStore extends PreferencesStore $this->insert($toBeInserted); } - $current = $this->preferences; - $toBeUpdated = array(); - foreach (array_filter( - array_keys(array_intersect_key($preferences, $this->preferences)), - function ($k) use ($current, $preferences) { return $current[$k] == $preferences[$k] ? false : true; } - ) as $key) { - $toBeUpdated[$key] = $preferences[$key]; - } + $toBeUpdated = array_intersect_key( + array_diff_assoc($preferences, $this->preferences), + array_diff_assoc($this->preferences, $preferences) + ); if (!empty($toBeUpdated)) { $this->update($toBeUpdated); } diff --git a/library/Icinga/User/Preferences/Store/IniStore.php b/library/Icinga/User/Preferences/Store/IniStore.php index 7b7d58503..eb1c4cbfb 100644 --- a/library/Icinga/User/Preferences/Store/IniStore.php +++ b/library/Icinga/User/Preferences/Store/IniStore.php @@ -81,12 +81,7 @@ class IniStore extends PreferencesStore public function save(Preferences $preferences) { $preferences = $preferences->toArray(); - $this->update( - array_merge( - array_diff_key($preferences, $this->preferences), - array_intersect_key($preferences, $this->preferences) - ) - ); + $this->update(array_diff_assoc($preferences, $this->preferences)); $this->delete(array_keys(array_diff_key($this->preferences, $preferences))); $this->write(); }