[Configuration] Fix saving of values when no previous value present #7507
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When there is a value in ConfigSettings but not Config, the value does
not get saved to the database but silently discarded. This is caused by
the save logic assuming that the ID always exists to update. However,
other logic in the configuration saving deletes from the Config table
if the value is "". This means that once a config option is set to the
empty string it can never be saved again. (This can also happen for
new ConfigSettings.)
Since the name used for the text field in the HTML is the Config table ID
(which doesn't exist) and not the ConfigSetting ID to support ConfigSetting
options that allow multiple entries, the name of the ID is "0" in the form
and can not be converted to a ConfigSetting to change the statement from an
update to an insertOnDuplicateUpdate. AllowMultiple settings, on the other
hand use "add-ConfigSettingID" or "remove-ConfigSettingID" as their name.
This modifies the template to use add-ConfigSettingID when the ConfigID is
"0" in order to have it inserted if it does not exist, regardless of the
AllowMultiple setting for the ConfigSetting.