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

Refactor set_config to improve handling for null values, improve DB performance and reduce complexity

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            kevinpham Kevin Pham
            kevinpham Kevin Pham
            Brendan Heywood Brendan Heywood
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona), Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Nov/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 31 minutes
                1h 31m