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

Get mainadmin user with get_admin() instead of deriving it from list of all admins

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: Administration
    • Labels:
    • Testing Instructions:
      Hide

      1/ run phpunit tests
      2/ install moodle
      3/ upgrade from 2.3 to master
      4/ optionally do some action that triggers notification of admins (see patch for list of affected plugins) - I suppose this step can be replaced by careful code review during integration

      Show
      1/ run phpunit tests 2/ install moodle 3/ upgrade from 2.3 to master 4/ optionally do some action that triggers notification of admins (see patch for list of affected plugins) - I suppose this step can be replaced by careful code review during integration
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w42_MDL-35904_m24_mainadmin

      Description

      Today, our moodle installation started to send out the update notification mails with some secondary admin's name as sender, not with the primary admin's name.

      Looking into /lib/pluginlib.php in cron_notify(), I realized that you fetch the list of all admins who should be notified with

      $admins = get_admins();

      and later derive the mainadmin as the first element of this list with

      $mainadmin = reset($admins);

      This derivation can be equal to the result of get_admin(), but you can't be sure. It would be great if you could replace

      reset($admins);

      with

      get_admin();

      Furthermore, this approach seems to be used several times as a quick grep showed to me:

      $ grep -r "reset(\$admins)" .
      ./lib/pluginlib.php:        $mainadmin = reset($admins);
      ./lib/installlib.php:    $admin = reset($admins);
      ./portfolio/googledocs/db/upgrade.php:    $mainadmin = reset($admins);
      ./portfolio/picasa/db/upgrade.php:    $mainadmin = reset($admins);
      ./repository/googledocs/db/upgrade.php:    $mainadmin = reset($admins);
      ./repository/picasa/db/upgrade.php:    $mainadmin = reset($admins);
      ./admin/cli/upgrade.php:$admin = reset($admins);

      Thanks in advance
      Alex

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              abias Alexander Bias
              Integrator:
              Dan Poltawski
              Tester:
              Andrew Davis
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Dec/12