Skip to content

Commit

Permalink
Merge branch 'MDL-80229-402' of https://github.com/davewoloszyn/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
HuongNV13 committed Jan 11, 2024
2 parents 38f083d + f59d914 commit 97e7e26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/configonlylib.php
Expand Up @@ -215,6 +215,9 @@ function min_get_slash_argument($clean = true) {
*/
function min_get_minimum_revision(): int {
static $timestamp = null;
// Days that will be deducted.
// Avoids errors when date comparisons are made at time of packaging for next release.
$tolerancedays = 2;

if ($timestamp === null) {
global $CFG;
Expand All @@ -224,7 +227,7 @@ function min_get_minimum_revision(): int {
// Parse the date components.
$year = intval(substr($datestring, 0, 4));
$month = intval(substr($datestring, 4, 2));
$day = intval(substr($datestring, 6, 2));
$day = intval(substr($datestring, 6, 2)) - $tolerancedays;
// Return converted GMT Unix timestamp.
$timestamp = gmmktime(0, 0, 0, $month, $day, $year);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/tests/configonlylib_test.php
Expand Up @@ -153,6 +153,8 @@ public function test_min_get_minimum_version(): void {
// This is fairly hard to write a test for, but we can at least check that it returns a number
// greater than the version when the feature was first introduced.
$firstintroduced = 1682294400; // Equivalent to 20230424 00:00:00 GMT.
// Deduct our two day tolerance.
$firstintroduced = $firstintroduced - (DAYSECS * 2);
$this->assertGreaterThanOrEqual($firstintroduced, min_get_minimum_revision());
}

Expand Down

0 comments on commit 97e7e26

Please sign in to comment.