catalyst / moodle-auth_outage

Planned, graduated user and admin friendly moodle outages
https://moodle.org/plugins/auth_outage
17 stars 32 forks source link

CLI maintenance mode uses hardcoded admin userid #301

Closed SashaAnastasi closed 1 year ago

SashaAnastasi commented 1 year ago

in classes/local/cli/clibase.php the function become_admin_user() has the line $user = $DB->get_record('user', ['id' => 2]);

This is not robust for sites that change the user with userid=2. The following exception is generated when this user is not present, or not an admin:

!!! Exception - Argument 1 passed to core\session\manager::set_user() must be an instance of stdClass, boolean given,
called in [dirroot]/auth/outage/classes/local/cli/clibase.php on line 130 !!!

Perhaps getting the userid of the primary site admin and using that would be a better approach.

brendanheywood commented 1 year ago

+1, pr's welcome, should be fairly trivial