Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-80848

Forum code does not handle things happening at the same time well

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 4.2.7, 4.3.4
    • Forum
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • 5
    • Team Alpha - Sprint 1 I3-2024

      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 this out reveals a variety failures:

      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 forum_discussion_update_last_post() not handling multiple posts in the same discussion at the same time.

      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.
      

      Caused by a similar problem in the post vault.

            Unassigned Unassigned
            dobedobedoh Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.