Skip to content

Commit

Permalink
MDL-79247 forum: Workaround same-time discussion modified dates bug
Browse files Browse the repository at this point in the history
Within the forum_get_discussion_neighbours() function of forum
when the discussions timemodified (last post) is the same, there
is a bug that does strange things when calculating the prev and
next discussions.

Note that, in real life, this is really hard to achieve, but in tests,
when multiple discussions and post can be created by generators in the
same second (specially when the test machine is quick), chances of
facing that problem are higher.

By adding 1 second wait, we ensure that the discussions won't have
the same timemodified (last post) and workaround the problem.

No mater of that, the problem deserves an issue to be created
so we guarantee from code that it also works ok when the same
timemodified (last post) situation happens.
  • Loading branch information
stronk7 committed Oct 1, 2023
1 parent d47d059 commit ee20a85
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mod/forum/tests/behat/discussion_navigation.feature
Expand Up @@ -51,6 +51,11 @@ Feature: A user can navigate to previous and next discussions
And I follow "Reply"
And I set the following fields to these values:
| Message | Answer to discussion |
# We need to wait a bit to guarantee that the post is created after the previous ones.
# because there is a bug in the forum_get_discussion_neighbours() when all the discussion
# last modified times are the same. See MDL-79247 for more details. Once that bug is fixed
# we can remove this wait.
And I wait "1" seconds
And I press "Post to forum"
And I should not see "Discussion 2"
And I should see "Discussion 3"
Expand Down

0 comments on commit ee20a85

Please sign in to comment.