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

Forum backup encode_content_links fails for parent links with & characters

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9.13, 2.0.4, 2.1.1, 2.9.4, 3.0.1, 3.1
    • 2.9.5, 3.0.3
    • Backup, Forum
    • MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-29506-master
    • Easy
    • 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.

    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

        Activity

          People

            rushi963 Rushikesh Nalla
            davosmith Davo Smith
            Andrew Lyons Andrew Lyons
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Damyon Wiese Damyon Wiese
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Adrian Greeve, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Mar/16