Moodle
  1. Moodle
  2. MDL-18470

unrequired global $CFG in get_admin()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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
    • Rank:
      31486

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

      1. patch2.txt
        0.7 kB
        Siddharth Prakash Singh

        Activity

        Hide
        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
        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
        Andrew Davis added a comment -

        Implemented in both the 1.9 and 2.0 branches.

        Show
        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: