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

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


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 4.2.7, 4.3.4
    • Forum
    • 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.


      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
      @@ @@

      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
            0 Vote for this issue
            5 Start watching this issue


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