The way that Moodle currently sets default values for config settings is through literal values in the code, such as in the following example. This is quite poor.
A number of bugs have come about because, through various circumstances, config values are not being set and this has an impact on the system when such settings are used.
One solution to this problem is to pre-populate the global config object $CFG with all default values, before over-writing these defaults with values from the DB. It might also be useful to start with a default object ($DEFAULT) that is copied as the config object ($CFG) so that default values can always be checked later. This would ensure that:
- all global config settings are guaranteed to have a value (would that lead to sloppy checking?), and
- the defaults for config values would be defined in a common place, and can be referred to when needed, instead of relying on literal values.