WR #490867 auth_outage Review changes - avoid mutating svgicons before a redirect and update tests for the access key and svgicons changes

This commit is contained in:
Waleed Hassan
2026-07-12 23:45:42 +01:00
parent 1b2979f8e6
commit a6e465b7a3
3 changed files with 22 additions and 12 deletions
+12 -4
View File
@@ -154,15 +154,23 @@ final class infopage_test extends \auth_outage\base_testcase {
}
/**
* Tests the constructor enables SVG support.
* Tests that rendering the page enables SVG support and restores the previous value afterwards.
*/
public function test_svgicons_is_true(): void {
public function test_svgicons_is_restored_after_output(): void {
global $CFG;
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
$outage = $this->get_dummy_outage();
$CFG->svgicons = false;
new infopage();
self::assertTrue($CFG->svgicons);
$info = new infopage(['outage' => $outage, 'static' => false]);
// Constructing the page should not touch $CFG->svgicons.
self::assertFalse($CFG->svgicons);
$info->get_output();
// Svgicons should be restored to its original value once rendering has finished.
self::assertFalse($CFG->svgicons);
}
}
+4 -4
View File
@@ -272,7 +272,7 @@ if ((time() >= 123) && (time() < 456)) {
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
}
// Put access key as a cookie if given. This stops the need to put it as a url param on every request.
$urlaccesskey = optional_param('accesskey', null, PARAM_TEXT);
$urlaccesskey = optional_param('accesskey', null, PARAM_ALPHANUM);
$isphpunit = defined('PHPUNIT_TEST');
if (!empty($urlaccesskey) && !$isphpunit) {
@@ -318,7 +318,7 @@ e.e.e.e/20');
}
if (true && $accesskeyblocked) {
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: '. $useraccesskey .' -->';
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: ' . htmlspecialchars($useraccesskey ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' -->';
}
if (!$isphpunit) {
@@ -358,7 +358,7 @@ if ((time() >= 123) && (time() < 456)) {
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
}
// Put access key as a cookie if given. This stops the need to put it as a url param on every request.
$urlaccesskey = optional_param('accesskey', null, PARAM_TEXT);
$urlaccesskey = optional_param('accesskey', null, PARAM_ALPHANUM);
$isphpunit = defined('PHPUNIT_TEST');
if (!empty($urlaccesskey) && !$isphpunit) {
@@ -402,7 +402,7 @@ if ((time() >= 123) && (time() < 456)) {
}
if (true && $accesskeyblocked) {
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: '. $useraccesskey .' -->';
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: ' . htmlspecialchars($useraccesskey ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' -->';
}
if (!$isphpunit) {