Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-35138

Ensure default values for config settings are set

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_27_STABLE

      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.

      /admin/settings/frontpage.php, lines 50-52

      $temp->add(new admin_setting_configtext('commentsperpage', new lang_string('commentsperpage', 'admin'), '', 15, PARAM_INT));
       
      $temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT));

      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.

            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.