-
Bug
-
Resolution: Fixed
-
Critical
-
4.2.7, 4.3.4
-
3
-
Team Alpha - Sprint 3 I4-2024, Team Alpha - Planning I1-2025
Problem
During my work on MDL-80838 I discovered a load of things that do not cope well with lots of things happening at the same time.
A workaround in the unit test generators hides a wealth of sins. This fairly tiny hack probably hasn't been noticed for the past 11 years and so we have real bugs which are not shown by unit tests as a result.
The hack:
- was introduced in
MDL-30102. - https://github.com/moodle/moodle/blob/3fc907e3d8646d53b744cbeb2820f5a060cc86ee/mod/forum/tests/generator/lib.php#L253-L254
- When we use a generator to create a post, we make use of a $time variable, which is created as:
// Variable to store time.
|
$time = time() + $this->forumpostcount;
|
- This means that the time will always increment for posts and we never get multiple posts from the same time.
Taking the hack out reveals a variety failures:
- Caused by forum_discussion_update_last_post() not handling multiple posts in the same discussion at the same time.
1) mod_forum\lib_test::test_forum_update_post_keeps_discussions_usermodified
|
Failed asserting that two strings are equal.
|
--- Expected
|
+++ Actual
|
@@ @@
|
-'192001'
|
+'192000'
|
|
/Users/nicols/Sites/moodles/sm/moodle/mod/forum/tests/lib_test.php:3449
|
/Users/nicols/Sites
|
- Caused by a similar problem in the post vault.
1) mod_forum\externallib_test::test_mod_forum_get_discussion_posts
|
Failed asserting that two arrays are equal.
|
2) mod_forum\externallib_test::test_mod_forum_get_forum_discussions_paginated
|
Failed asserting that two arrays are equal.
|
- Discovered while testing
-
MDL-80838 Add support for PSR-20 (Clock) to allow better time management
-
- Closed
-