diff --git a/lib/configonlylib.php b/lib/configonlylib.php index bcdfa9bee90..cddb3653110 100644 --- a/lib/configonlylib.php +++ b/lib/configonlylib.php @@ -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; @@ -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); } diff --git a/lib/tests/configonlylib_test.php b/lib/tests/configonlylib_test.php index 8a900095376..2bd8c8ca04d 100644 --- a/lib/tests/configonlylib_test.php +++ b/lib/tests/configonlylib_test.php @@ -153,6 +153,8 @@ class configonlylib_test extends \advanced_testcase { // 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 = 1669593600; // Equivalent to 20221128 00:00:00 GMT. + // Deduct our two day tolerance. + $firstintroduced = $firstintroduced - (DAYSECS * 2); $this->assertGreaterThanOrEqual($firstintroduced, min_get_minimum_revision()); }