diff --git a/Sources/Config.php b/Sources/Config.php index f2082e4f8f..501e1afb08 100644 --- a/Sources/Config.php +++ b/Sources/Config.php @@ -1289,9 +1289,12 @@ public static function updateModSettings(array $change_array, bool $update = fal return; } - // Go check if there is any setting to be removed. - $to_remove = array_filter($change_array, fn($setting) => $setting === null); - $change_array = array_diff_key($change_array, $to_remove); + // Go check if there is any setting to be removed. The names are what we + // want here, not the nulls they are set to: {array_string:remove} + // binds the values, so handing it the whole array asks the database to + // delete every setting called ''. + $to_remove = array_keys($change_array, null, true); + $change_array = array_diff_key($change_array, array_flip($to_remove)); // Proceed with the deletion. if (!empty($to_remove)) { @@ -1302,6 +1305,15 @@ public static function updateModSettings(array $change_array, bool $update = fal 'remove' => $to_remove, ], ); + + // The copy we are holding and the cached one both have to lose them + // as well. Otherwise the setting is still here for the rest of this + // request, and back again on the next one. + foreach ($to_remove as $variable) { + unset(self::$modSettings[$variable]); + } + + Cache\CacheApi::put('modSettings', null, 90); } // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.