-
Bug
-
Resolution: Fixed
-
Minor
-
3.0.6, 3.1.2
-
MOODLE_30_STABLE, MOODLE_31_STABLE
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
Reusing old issue
I'm reusing this old issue, which failures we aren't getting anymore, to fix another problem related with test_get_next_scheduled_time() that is happening on Daylight Saving Time Begins dates of Europe/London (like today 28 March 2021).
I've kept the original issue after the double line, for the records and search-ability, but as said, we haven't got it over the last years (that I remember).
Problem
The test_get_next_scheduled_time() test does try with Europe/London timezone, and it performs the test on current day at 01:00 AM. And that works ok for 364 days.
But there is one day in the year (today, last Sunday of March), when that hour simply doesn't exist, because it's Daylight Saving Time Begins and, at 01:00, the clock changes to 02:00.
Reproduce
To reproduce it, just set your computer to Europe/London time, your clock to any time between 02:00 and 23:59, and run the --filter test_get_next_scheduled_time test. It will fail. Change to any other day of the year... and it will work perfectly.
Explanation:
That doesn't affect directly to the get_next_scheduled_time() because it will, correctly, return the next 01:00 date (Monday 01:00). But the expectation is wrong, because we are always expecting the next execution to happen 1 day (24h) after the previous one, but the day of Daylight Saving Time Begins, the next execution is only 1 day less 1 hour (23h) after the previous one (because the DST change "eats" the hour between 01:00 and 01:59).
Note this doesn't affect the Daylight Saving Time Ends (October) because that day, 01:00 exists without problem, and both the get_next_scheduled_time() and the DateInterval expectation (1 day) are correct.
So this is about to detect when we are in the Daylight Saving Time Begins day... and then change the expectation to be correct (1 day less 1 hour). And then verify that it works for any day of the year, not only for current 364.
Original issue description
Following was observed today for the first time on nightly
1) core_scheduled_task_testcase::test_get_next_scheduled_task
|
Failed asserting that core\task\scheduled_test_task Object (...) is an instance of class "\core\task\scheduled_test2_task".
|
|
/var/www/html/moodle/lib/tests/scheduled_task_test.php:309
|
/var/www/html/moodle/lib/phpunit/classes/advanced_testcase.php:80
|
|
To re-run:
|
vendor/bin/phpunit core_scheduled_task_testcase lib/tests/scheduled_task_test.php
|
|
FAILURES!
|
Tests: 5438, Assertions: 69297, Failures: 1, Skipped: 20.
|
|
Notice: Trying to get property of non-object in /var/www/html/moodle/lib/classes/string_manager_standard.php on line 135
|
PHP Notice: Trying to get property of non-object in /var/www/html/moodle/lib/classes/string_manager_standard.php on line 135
|
PHP Fatal error: Uncaught exception 'coding_exception' with message 'debug/codingerror
|
$a contents: A lock was created but not released at:
|
/var/www/html/moodle/lib/classes/task/manager.php on line 458
|
|
Code should look like:
|
|
$factory = \core\lock\lock_config::get_lock_factory('type');
|
$lock = $factory->get_lock(Resource id #2031382);
|
$lock->release(); // Locks must ALWAYS be released like this.
|
|
' in /var/www/html/moodle/lib/classes/lock/lock.php:117
|
Stack trace:
|
#0 [internal function]: core\lock\lock->__destruct()
|
#1 {main}
|
thrown in /var/www/html/moodle/lib/classes/lock/lock.php on line 117
|
|
Fatal error: Uncaught exception 'coding_exception' with message 'debug/codingerror
|
$a contents: A lock was created but not released at:
|
/var/www/html/moodle/lib/classes/task/manager.php on line 458
|
|
Code should look like:
|
|
$factory = \core\lock\lock_config::get_lock_factory('type');
|
$lock = $factory->get_lock(Resource id #2031382);
|
$lock->release(); // Locks must ALWAYS be released like this.
|
|
' in /var/www/html/moodle/lib/classes/lock/lock.php:117
|
Stack trace:
|
#0 [internal function]: core\lock\lock->__destruct()
|
#1 {main}
|
thrown in /var/www/html/moodle/lib/classes/lock/lock.php on line 117
|
Build step 'Execute shell' marked build as failure
|
- has a non-specific relationship to
-
MDL-47480 Scheduled Tasks are returned in random order by get_next_scheduled_task
- Closed
- has been marked as being related by
-
MDL-47546 Unreleased lock throws exception outside of phpunit
- Closed
- is duplicated by
-
MDL-71236 PHP unit test lib/tests/scheduled_task_test.php fails with daylight savings
- Closed