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

Forum backup encode_content_links fails for parent links with & characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.13, 2.0.4, 2.1.1, 2.9.4, 3.0.1, 3.1
    • Fix Version/s: 2.9.5, 3.0.3
    • Component/s: Backup, Forum
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a course with a forum and a page
      2. Post a message to the forum and a reply to this message.
      3. Switch the view to 'display replies in threaded form'.
      4. Click on the reply to get the link with the '&parent=YY' parameter at the end of it.
      5. Add this link to the page (or webpage).
        (You can use the HTML view to confirm the '&parent=YY' is saved as '&parent=YY').
      6. Backup the course (including the forum and page).
      7. Restore as a new course.

      Expected:
      Page (or webpage) links to the forum in the newly restored course.

      Actual:
      Page (or webpage) links to the forum in the old course.

      Show
      Create a course with a forum and a page Post a message to the forum and a reply to this message. Switch the view to 'display replies in threaded form'. Click on the reply to get the link with the '&parent=YY' parameter at the end of it. Add this link to the page (or webpage). (You can use the HTML view to confirm the '&parent=YY' is saved as '&parent=YY'). Backup the course (including the forum and page). Restore as a new course. Expected: Page (or webpage) links to the forum in the newly restored course. Actual: Page (or webpage) links to the forum in the old course.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Pull Master Branch:
      MDL-29506-master

      Description

      encode_content_links assumes URLs of the form:

      [wwwroot]/mod/forum/discus.php?d=XX&parent=YY

      It fails on URLs of the form (note encoded & ):

      [wwwroot]/mod/forum/discus.php?d=XX&parent=YY

      The fix for both Moodle versions is as follows:

      find the (forum_)encode_content_links function.

      Find the line which contains (the variable at the start of the line is different in M1.9/M2.x):

      = "/(".$base."\/mod\/forum\/discuss.php?d\=)([0-9])\&parent\=([0-9])/";

      Change it to:

      "/(".$base."\/mod\/forum\/discuss.php?d\=)([0-9])(?:\&|\&)parent\=([0-9])/";

      This will cope with URLs with & or & in them.

        Attachments

        1. patch.txt
          1 kB
          Rushikesh Nalla

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Mar/16