From 2a7556eb75f4c816d868f14929164e2d5dfd5240 Mon Sep 17 00:00:00 2001 From: Peter Burnett Date: Mon, 19 Jan 2026 13:45:20 +1000 Subject: [PATCH] chore: ci Fixes --- classes/local/outagelib.php | 14 ++++++++++++-- db/upgrade.php | 1 - lang/en/auth_outage.php | 8 ++------ tests/local/cli/waitforit_test.php | 4 ++-- .../controllers/maintenance_static_page_test.php | 3 +-- views/info/content.php | 7 +++---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index 93722c2..b23f99c 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -279,6 +279,7 @@ class outagelib { * @param int $stoptime Outage stop time. * @param string $allowedips List of IPs allowed. * @param string|null $accesskey access key, or null if no access key set. + * @param string|null $metadata Metadata to set in headers, or null if none. * * @return string * @throws invalid_parameter_exception @@ -370,8 +371,17 @@ EOT; $search = ['{{STARTTIME}}', '{{STOPTIME}}', '{{USEALLOWEDIPS}}', '{{ALLOWEDIPS}}', '{{USEACCESSKEY}}', '{{ACCESSKEY}}', '{{YOURIP}}', '{{COOKIESECURE}}', '{{COOKIEHTTPONLY}}', '{{METADATA}}']; // Note that var_export is required because (string) false == '', not 'false'. - $replace = [$starttime, $stoptime, var_export(!empty($allowedips), true), $allowedips, var_export(!empty($accesskey), true), - $accesskey, getremoteaddr('n/a'), var_export($cookiesecure, true), var_export($cookiehttponly, true), var_export($metadata, true)]; + $replace = [ + $starttime, + $stoptime, + var_export(!empty($allowedips), true), + $allowedips, + var_export(!empty($accesskey), true), + $accesskey, + getremoteaddr('n/a'), + var_export($cookiesecure, true), + var_export($cookiehttponly, true), + var_export($metadata, true)]; return str_replace($search, $replace, $code); } diff --git a/db/upgrade.php b/db/upgrade.php index 8d27d7a..8d28ef6 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -62,7 +62,6 @@ function xmldb_auth_outage_upgrade($oldversion) { } if ($oldversion < 2026011301) { - // Define field metadata to be added to auth_outage. $table = new xmldb_table('auth_outage'); $field = new xmldb_field('metadata', XMLDB_TYPE_TEXT, null, null, null, null, null, 'accesskey'); diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 5d72a9f..6972aab 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -32,9 +32,9 @@ $string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup t $string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.'; $string['autostart'] = 'Auto start maintenance mode.'; $string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.'; +$string['autostartforcedoff'] = 'Force off'; $string['autostartoff'] = 'Default off'; $string['autostarton'] = 'Default on'; -$string['autostartforcedoff'] = 'Force off'; $string['builtinallowediplist'] = 'Builtin Allowed IP List'; $string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI'; $string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10"; @@ -144,6 +144,7 @@ $string['outagefinishwarning'] = 'You are about to mark this outage as finished. $string['outageslistfuture'] = 'Planned outages'; $string['outageslistpast'] = 'Outage history'; $string['pluginname'] = 'Outage manager'; +$string["privacy:no_data_reason"] = "The Outage authentication plugin does not store any personal data."; $string['removeselectors'] = 'Remove selectors'; $string['removeselectorsdescription'] = 'CSS selectors to remove when rendering a static themed maintenance page. One selector per line.'; $string['settingssectiondefaults'] = 'Default Outage Parameters'; @@ -173,8 +174,3 @@ $string['warningduration'] = 'Warning duration'; $string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.'; $string['warningdurationerrorinvalid'] = 'Warning duration must be positive.'; $string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.
Untick "Auto start maintenance mode" if you want to prevent this.'; - -/* - * Privacy provider (GDPR) - */ -$string["privacy:no_data_reason"] = "The Outage authentication plugin does not store any personal data."; diff --git a/tests/local/cli/waitforit_test.php b/tests/local/cli/waitforit_test.php index 350b79a..03c9d5f 100644 --- a/tests/local/cli/waitforit_test.php +++ b/tests/local/cli/waitforit_test.php @@ -160,7 +160,7 @@ final class waitforit_test extends cli_testcase { /** * Tests the countdown. */ - public function test_countdown() { + public function test_countdown(): void { self::setAdminUser(); $now = time(); outagedb::save(new outage([ @@ -189,7 +189,7 @@ final class waitforit_test extends cli_testcase { /** * Tests if the outage changed while waiting. */ - public function test_outagechanged() { + public function test_outagechanged(): void { self::setAdminUser(); $now = time(); $id = outagedb::save(new outage([ diff --git a/tests/local/controllers/maintenance_static_page_test.php b/tests/local/controllers/maintenance_static_page_test.php index 3155db3..2aa6092 100644 --- a/tests/local/controllers/maintenance_static_page_test.php +++ b/tests/local/controllers/maintenance_static_page_test.php @@ -583,7 +583,7 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase { /** * Test meta refresh maximum 5 minutes. */ - public function test_meta_refresh_maximum_5seconds() { + public function test_meta_refresh_maximum_5seconds(): void { $this->resetAfterTest(true); $html = "\n" . 'Title' . @@ -593,7 +593,6 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase { $page->set_max_refresh_time(5); $page->generate(); $generated = trim(file_get_contents($page->get_io()->get_template_file())); - return $generated; self::assertStringContainsString('', $generated); } diff --git a/views/info/content.php b/views/info/content.php index 8a01cef..0f44cce 100644 --- a/views/info/content.php +++ b/views/info/content.php @@ -44,14 +44,13 @@ defined('MOODLE_INTERNAL') || die(); -$viewbag['outage']->get_warning_duration(), '15secondsbefore' => -15, 'start' => 0, 'endofoutage' => $viewbag['outage']->get_duration_planned() - 1, - ] as $title => $delta - ) { + ]; + foreach ($params as $title => $delta) { $adminlinks[] = html_writer::link( new moodle_url( '/auth/outage/info.php',