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

    • MOODLE_23_STABLE
    • MOODLE_24_STABLE
    • w42_MDL-35904_m24_mainadmin
    • 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

      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

            skodak Petr Skoda
            abias Alexander Bias
            Dan Poltawski Dan Poltawski
            Andrew Davis Andrew Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.