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

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

XMLWordPrintable

    • 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:

              // 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.
      

       

            andrew.gosali@moodle.com Andrew Gosali
            dobedobedoh Andrew Lyons
            Glyn (Mathew) May Glyn (Mathew) May
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week, 3 days, 4 hours, 45 minutes
                1w 3d 4h 45m

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