mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-80229 core: Add tolerance to min_get_minimum_revision
This commit is contained in:
parent
94ad185d09
commit
3fe8dbd027
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user