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

unrequired global $CFG in get_admin()

    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;
      }

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            spsneo Siddharth Prakash Singh added a comment -

            Yeah the above suggestion is true. I created a patch with the modifications mentioned in the above comment.

            Show
            spsneo Siddharth Prakash Singh added a comment - Yeah the above suggestion is true. I created a patch with the modifications mentioned in the above comment.
            Hide
            andyjdavis Andrew Davis added a comment -

            Implemented in both the 1.9 and 2.0 branches.

            Show
            andyjdavis Andrew Davis added a comment - Implemented in both the 1.9 and 2.0 branches.

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

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