Skip to content
Merged
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
18 changes: 15 additions & 3 deletions Sources/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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.
Expand Down