You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently i've encountered a problem with storing null as a setting value: a new non-null value isnt stored into database if such a key already exists and have a null value.
// This will create a new setting with nullable valuesettings()->set([
'key' => null,
]);
settings()->save();
// That new value will not be stored into database, the actual value will remain "null"settings()->set([
'key' => 'value',
]);
settings()->save();
The cause of this problem is that DatabaseSettingStore uses the isset() function to determine if a specific key exists, but that function does not consider null values. I would suggest to use the array_key_exists() function instead:
A use-case for this improvement is that sometimes (my case :)) you have a single form for the project settings and some of them may not have a value (null by default) and it is handy to just save all validated settings into database, event if some values are null:
Hello,
Recently i've encountered a problem with storing
null
as a setting value: a new non-null value isnt stored into database if such a key already exists and have anull
value.The cause of this problem is that
DatabaseSettingStore
uses theisset()
function to determine if a specific key exists, but that function does not considernull
values. I would suggest to use thearray_key_exists()
function instead:A use-case for this improvement is that sometimes (my case :)) you have a single form for the project settings and some of them may not have a value (
null
by default) and it is handy to just save all validated settings into database, event if some values arenull
:The text was updated successfully, but these errors were encountered: