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

Book HTML zip import incorrect URL produced for internal linking to other chapters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.4.7, 2.5.3
    • Component/s: Book
    • Labels:
    • Testing Instructions:
      Hide

      1) Create a new book module and save and display.
      2) Progress to the import chapter page (Administration > Import chapter).
      3) Use the attached bookimporttest.zip file as the Zip file, and leave the Type as the default Each Html file represents one chapter.
      4) Once the import processing has completed view the first of the two pages (named a.html and b.html). There is a link on each page to the other page. Without this patch the links are broken (though the addition of 'id' in the url will correct them).

      Show
      1) Create a new book module and save and display. 2) Progress to the import chapter page (Administration > Import chapter). 3) Use the attached bookimporttest.zip file as the Zip file, and leave the Type as the default Each Html file represents one chapter. 4) Once the import processing has completed view the first of the two pages (named a.html and b.html). There is a link on each page to the other page. Without this patch the links are broken (though the addition of 'id' in the url will correct them).
    • Workaround:
      Hide

      Do not use links in html files that you are using to import to a book

      Show
      Do not use links in html files that you are using to import to a book
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-41473-master

      Description

      Scenario:
      HTML file A has a relative link to HTML file B. Both files are added to a Zip. The Zip is imported into a Book and chapters are created from the HTML files. The Book module attempts to preserve the link from A to B, using the new paths created as A and B are now chapters in the book. However, there is an error in the link created as it uses 'chapter' as a parameter instead of 'chapterid'.

      Solution:

      In mod/book/tool/importhtml/locallib.php

      In function toolbook_importhtml_import_chapters

      Line 140/141

      Change

      $newcontent = str_replace($match, 'href="'.new moodle_url('/mod/book/view.php',
      array('id'=>$context->instanceid, 'chapter'=>$target->id)).'"', $newcontent);

      to

      $newcontent = str_replace($match, 'href="'.new moodle_url('/mod/book/view.php',
      array('id'=>$context->instanceid, 'chapterid'=>$target->id)).'"', $newcontent);

      Sorry, I'm just an occasional user so not used to creating patch files myself. Hope it helps!

        Attachments

          Activity

            People

            Assignee:
            jb23347 John Beedell
            Reporter:
            mattcornock Matt Cornock
            Peer reviewer:
            Ankit Agarwal
            Integrator:
            Damyon Wiese
            Tester:
            Sam Hemelryk
            Participants:
            Component watchers:
            David Jones, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Nov/13