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

Splitting a discussion creates discussion record with an incorrect first post author

    XMLWordPrintable

Details

    • MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-65573-master-2
    • Hide

      Prerequisite:

      • A course with a forum activity
      • 2 users(U1 & U2) enrolled into the course
      • A discussion(D1) within the forum - with replies by all users involved
      • A discussion(D2) within the forum created via the split functionality(of D1) in a way that the 2 discussions have different authors for their first posts (Do this before the patch is applied)
      • DB access to confirm.

      Instructions:

      Case 1 - Upgrade steps - fix existing

      1. Access to DB and execute the following SQL query: 

        SELECT * FROM mdl_forum_discussions AS d
        INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id
        WHERE d.userid <> p.userid

      1. Confirm the previous query returns one row.
      2. Apply the patch.
      3. Run through the upgrade steps.
      4. Access to DB and execute the following SQL query: 

      SELECT * FROM mdl_forum_discussions AS d
      INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id
      WHERE d.userid <> p.userid

      1. Confirm the previous query now returns 0 rows.

      Case 2 - Split functionality - new splits

      1. As user U1, post a reply in D1.
      2. As an admin, go to discussion D1.
      3. Split U1's post from #1 into a new discussion(D3).
      4. Access to DB and execute the following SQL query: 

        SELECT * FROM mdl_forum_discussions AS d
        INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id
        WHERE d.userid <> p.userid

      1. Confirm the previous query still returns 0 rows.
      Show
      Prerequisite: A course with a forum activity 2 users(U1 & U2) enrolled into the course A discussion(D1) within the forum - with replies by all users involved A discussion(D2) within the forum created via the split functionality(of D1) in a way that the 2 discussions have different authors for their first posts ( Do this before the patch is applied ) DB access to confirm. Instructions: Case 1 - Upgrade steps - fix existing Access to DB and execute the following SQL query:  SELECT * FROM mdl_forum_discussions AS d INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id WHERE d.userid <> p.userid Confirm the previous query returns one row. Apply the patch. Run through the upgrade steps. Access to DB and execute the following SQL query:  SELECT * FROM mdl_forum_discussions AS d INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id WHERE d.userid <> p.userid Confirm the previous query now returns 0 rows. Case 2 - Split functionality - new splits As user U1, post a reply in D1. As an admin, go to discussion D1. Split U1's post from #1 into a new discussion(D3). Access to DB and execute the following SQL query:  SELECT * FROM mdl_forum_discussions AS d INNER JOIN mdl_forum_posts AS p ON d.firstpost = p.id WHERE d.userid <> p.userid Confirm the previous query still returns 0 rows.

    Description

      When splitting a discussion we create a new discussion from the point of the split and move all reply posts into that new discussion.

      However the new discussion record doesn't have the "userid" field updated to match the id of the new first post user, it still references the same id as the discussion that was split.

      This results in a discussion record with invalid data where the userid field doesn't actually match the id of the author of the first post.

      Attachments

        Issue Links

          Activity

            People

              peterdias Peter Dias
              ryanwyllie Ryan Wyllie
              Andrew Lyons Andrew Lyons
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Janelle Barcega Janelle Barcega
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/20

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours, 51 minutes
                  5h 51m