mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Preventing cli/finish.php to run while in maintenance mode.
This commit is contained in:
@@ -78,6 +78,11 @@ class cli_exception extends Exception {
|
||||
*/
|
||||
const ERROR_PLUGIN_DISABLED = 8;
|
||||
|
||||
/**
|
||||
* Moodle maintenance mode is enabled.
|
||||
*/
|
||||
const ERROR_MAINTENANCE_MODE = 9;
|
||||
|
||||
/**
|
||||
* cliexception constructor.
|
||||
* @param string $message An explanation of the exception.
|
||||
|
||||
@@ -46,9 +46,9 @@ class finish extends clibase {
|
||||
public function generate_options() {
|
||||
// Do not provide some defaults, if cloning an outage we need to know which parameters were provided.
|
||||
$options = [
|
||||
'help' => false,
|
||||
'help' => false,
|
||||
'outageid' => null,
|
||||
'active' => false,
|
||||
'active' => false,
|
||||
];
|
||||
return $options;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ class finish extends clibase {
|
||||
*/
|
||||
public function generate_shortcuts() {
|
||||
return [
|
||||
'h' => 'help',
|
||||
'h' => 'help',
|
||||
'id' => 'outageid',
|
||||
'a' => 'active',
|
||||
'a' => 'active',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -75,6 +75,12 @@ class finish extends clibase {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot run during CLI_MAINTENANCE mode.
|
||||
if (CLI_MAINTENANCE) {
|
||||
throw new cli_exception(get_string('cliinmaintenancemode', 'auth_outage'),
|
||||
cli_exception::ERROR_MAINTENANCE_MODE);
|
||||
}
|
||||
|
||||
// Requires outageid or active but not both at the same time.
|
||||
$byid = !is_null($this->options['outageid']);
|
||||
$byactive = $this->options['active'];
|
||||
|
||||
Reference in New Issue
Block a user