From 15cd72b36c7570a141882598f118128a30a6e14c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Jul 2024 16:19:12 +0200 Subject: [PATCH 1/2] ChannelForm: Don't filter stored configuration It's been filtered before, otherwise it wouldn't be stored, would it? --- application/forms/ChannelForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/ChannelForm.php b/application/forms/ChannelForm.php index f710de4a..0394e89c 100644 --- a/application/forms/ChannelForm.php +++ b/application/forms/ChannelForm.php @@ -218,7 +218,7 @@ public function editChannel(): void $storedValues = $this->fetchDbValues(); $channel['config'] = json_encode($this->filterConfig($channel['config'])); - $storedValues['config'] = json_encode($this->filterConfig($storedValues['config'])); + $storedValues['config'] = json_encode($storedValues['config']); if (! empty(array_diff_assoc($channel, $storedValues))) { $channel['changed_at'] = time() * 1000; From 1079dc608e53eb2a6e04e8cad37078f447b2b050 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Jul 2024 16:19:46 +0200 Subject: [PATCH 2/2] ChannelForm: Store cleared default options as empty string --- application/forms/ChannelForm.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/application/forms/ChannelForm.php b/application/forms/ChannelForm.php index 0394e89c..7b03b7e1 100644 --- a/application/forms/ChannelForm.php +++ b/application/forms/ChannelForm.php @@ -397,17 +397,19 @@ protected function fromCurrentLocale(array $localeMap): ?string */ private function filterConfig(array $config): array { - return array_filter( - $config, - function ($configItem, $key) { - if (isset($this->defaultChannelOptions[$key])) { - return $this->defaultChannelOptions[$key] !== $configItem; + foreach ($config as $key => $value) { + if (isset($this->defaultChannelOptions[$key])) { + if ($value === null) { + $config[$key] = ''; + } elseif ($this->defaultChannelOptions[$key] === $value) { + unset($config[$key]); } + } elseif ($value === null) { + unset($config[$key]); + } + } - return $configItem !== null; - }, - ARRAY_FILTER_USE_BOTH - ); + return $config; } /**