Skip to content

Commit

Permalink
Merge branch 'MDL-74886-400' of https://github.com/lameze/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_400_STABLE
  • Loading branch information
junpataleta committed Jun 29, 2022
2 parents ced2e3a + 25212b8 commit 42a0b73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/adminlib.php
Expand Up @@ -4010,7 +4010,9 @@ public function write_setting($data) {
return '';
}

$seconds = (int)($data['v']*$data['u']);
$unit = (int)$data['u'];
$value = (int)$data['v'];
$seconds = $value * $unit;

// Validate the new setting.
$error = $this->validate_setting($seconds);
Expand Down
11 changes: 11 additions & 0 deletions lib/tests/admintree_test.php
Expand Up @@ -357,6 +357,17 @@ public function test_preventexecpath() {
$this->assertSame('', get_config('abc_cde', 'execpath'));
}

/**
* Test setting an empty duration displays the correct validation message.
*/
public function test_emptydurationvalue() {
$this->resetAfterTest();
$adminsetting = new admin_setting_configduration('abc_cde/duration', 'some desc', '', '');

// A value that isn't a number is treated as a zero, so we expect to see no error message.
$this->assertEmpty($adminsetting->write_setting(['u' => '3600', 'v' => 'abc']));
}

/**
* Test setting for blocked hosts
*
Expand Down

0 comments on commit 42a0b73

Please sign in to comment.