chore: ci Fixes

This commit is contained in:
Peter Burnett
2026-01-19 13:45:20 +10:00
parent 425ef963fb
commit 2a7556eb75
6 changed files with 20 additions and 17 deletions

View File

@@ -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);
}

View File

@@ -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');

View File

@@ -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.<br />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.";

View File

@@ -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([

View File

@@ -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 = "<!DOCTYPE html>\n" .
'<html><head><title>Title</title></head>' .
@@ -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('<meta http-equiv="refresh" content="5">', $generated);
}

View File

@@ -44,14 +44,13 @@ defined('MOODLE_INTERNAL') || die();
<?php if ($viewbag['admin']) : ?>
<?php
$adminlinks = [];
foreach (
[
$params = [
'startofwarning' => -$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',