Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.11.4, 4.0, 4.1
Description
https://github.com/moodle/moodle/blob/master/lib/moodlelib.php#L1447-L1453
I noticed here that the id check is not necessary if the value is null, and will result in an extra unneeded DB call.
Also recently learnt about the "unset_config" method which seems to do the same thing as set_config(name, null, pluginname), but optimised for when the value is null. Perhaps a few things should happen here.
1 - set config should redirect the handling to unset_config if the value provided is null.
2 - set config should have all the nullish checks within itself removed after the function redirect (in point 1)
3 - documentation updated to suggest that unset_config should be used instead of set_config when knowingly unsetting a config value. This will help avoid the extra function call overhead.
I wouldn't necessarily deprecate the nullish functionality in set_config purely because it's probably used everywhere for setting and unsetting values.