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

Forum does not display ancient discussions with usermodified = 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.7, 4.1.2
    • 4.0.2, 4.0.6, 4.1.1
    • Forum
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-75534-master-forum-usermodified-zero
    • Hide

      Run the fix query manually.

      Show
      Run the fix query manually.
    • Hide

      Note: Testing requires direct DB access.

      Environment setup

      1. Before applying the patch, log in as a teacher or an admin.
      2. Find any forum (such as course announcements or site news).
      3. Start a new discussion and post into the forum.
      4. Hover the discussion link and get know the discussion id from the URL: /mod/forum/discuss.php?d=XYZ (you will see a number instead of XYZ - that's the id you are looking for).
      5. Update the record in the database to simulate what very early Moodle versions would do (replace XYZ with the actual id number):

      UPDATE mdl_forum_discussions SET usermodified = 0 WHERE id = XYZ;
      

      Test

      1. Test: Confirm that the discussion is not displayed.
      2. Upgrade the site.
      3. Test: Confirm that the discussion is displayed again.
      Show
      Note: Testing requires direct DB access. Environment setup Before applying the patch, log in as a teacher or an admin. Find any forum (such as course announcements or site news). Start a new discussion and post into the forum. Hover the discussion link and get know the discussion id from the URL: /mod/forum/discuss.php?d=XYZ (you will see a number instead of XYZ - that's the id you are looking for). Update the record in the database to simulate what very early Moodle versions would do (replace XYZ with the actual id number): UPDATE mdl_forum_discussions SET usermodified = 0 WHERE id = XYZ; Test Test : Confirm that the discussion is not displayed. Upgrade the site. Test : Confirm that the discussion is displayed again.

      As noticed today by dougiamas, some very first posts from the very first Moodle forum https://moodle.org/mod/forum/view.php?f=1 were not displayed. I was able to reproduce the problem and trace it down to https://github.com/moodle/moodle/blob/17ee0726933c7c6410aca0e1edc445f795774c07/mod/forum/classes/local/vaults/discussion_list.php#L156

      $tables .= ' JOIN {user} la ON la.id = ' . $alias . '.usermodified';
      

      The SQL that fetches records from the database, uses the INNER JOIN against the user table on the value forum_discussions.usermodified. For new discussions, Moodle sets usermodified to the author of the first post so it works well.

      But very early Moodle versions used to leave that field set to zero (that was changed somewhere around versions 1.1 or 1.2). So in our case, discussions that were never replied to, still had the usermodified set to 0 for these 20 years old discussions. And so they were not displayed.

      The fix is simple:

      UPDATE forum_discussions SET usermodified = userid WHERE usermodified = 0;
      

      and I think it is something we should do in a forum upgrade step.

        1. master.gif
          master.gif
          719 kB
        2. 401.gif
          401.gif
          1.39 MB
        3. 400.gif
          400.gif
          548 kB

            mudrd8mz David Mudrák (@mudrd8mz)
            mudrd8mz David Mudrák (@mudrd8mz)
            Paul Holden Paul Holden
            Andrew Lyons Andrew Lyons
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 days, 56 minutes
                3d 56m

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