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

unrequired global $CFG in get_admin()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.4
    • Fix Version/s: 1.9.8
    • Component/s: Libraries
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      the "get_admin()" function (lib/datalib.php) has an unnecessary global $CFG.

      Also, the logic seems unnecessarily longwinded to me, so I suggest the following as a shorter, clearer alternative, that behaves exactly as the current function does:

      function get_admin () {
      static $admin;
      if (! isset($admin)) {
      if (! $admins = get_admins())

      { return false; }

      $admin = reset($admins);
      }
      return $admin;
      }

        Attachments

          Activity

            People

            Assignee:
            andyjdavis Andrew Davis
            Reporter:
            xxxxxxx Gordon Bateson
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              25/Mar/10