Moodle
  1. Moodle
  2. MDL-35305

Backing up a course containing a wiki with linked files fails to restore

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1, 2.3, 2.5.5, 2.6.2, 2.7
    • Fix Version/s: 2.5.6, 2.6.3
    • Component/s: Wiki (2.x)
    • Labels:

      Description

      When I try to restore a course containing a wiki with a linked file, the text of the wiki is right and the link is there, but the file at the end of the link is missing.

      Steps:
      1. Create a new course with a wiki
      2. Create a wiki page with some text and a link to a file
      3. Backup the course (including user data and user files)
      4. Restoring the backup file into a new course
      5. Access the wiki and press the link on the wiki page

      Editing the backup file I noticed that the linked files are not even included, so I tried debugging it.
      Editing backup_wiki_stepslib.php I found that changing the line

      $page->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid

      to

      $page->annotate_files('mod_wiki', 'attachments', null'); // This file area hasn't itemid

      will get the linked files included into the backup file, but the restore process still doesn't work.
      I am not sure how to debug this further, so I need some help resolving this issue.

      Br. Peter

        Gliffy Diagrams

          Activity

          Hide
          Tatsuya Shirai added a comment - - edited

          me too...

          I added a image file to 'files'tab area manually, then the image file in wiki page is displayed.

          Please fix this bug.

          Show
          Tatsuya Shirai added a comment - - edited me too... I added a image file to 'files'tab area manually, then the image file in wiki page is displayed. Please fix this bug.
          Hide
          Tatsuya Shirai added a comment - - edited

          Humm. All files in backup.mbz are restored in filestorage.
          But, item ID is illegal.
          I changed item id (mdl_files), then the file appear in 'files'tab field.
          Recorded item id is old one.


          sorry, above information is not true;
          If you change $this->add\related_files('mod_wiki', 'attachments', 'wiki_page'); 'wiki_page' -> null, all files will be stored to fileStorage.
          But it's not good solution...

          However, itemid is a important key of this problem.

          Show
          Tatsuya Shirai added a comment - - edited Humm. All files in backup.mbz are restored in filestorage. But, item ID is illegal. I changed item id (mdl_files), then the file appear in 'files'tab field. Recorded item id is old one. — sorry, above information is not true; If you change $this->add\related_files('mod_wiki', 'attachments', 'wiki_page'); 'wiki_page' -> null, all files will be stored to fileStorage. But it's not good solution... However, itemid is a important key of this problem.
          Hide
          Tatsuya Shirai added a comment - - edited

          In mod/wiki/backup/moodle2/backup_wiki_stepslib.php, function define_structure():

          Original
          $page->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid
          is
          $subwiki->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid
          isn't?

          Show
          Tatsuya Shirai added a comment - - edited In mod/wiki/backup/moodle2/backup_wiki_stepslib.php, function define_structure(): Original $page->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid is $subwiki->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid isn't?
          Hide
          Tatsuya Shirai added a comment -

          And, in mod/wiki/backup/moodle2/restore_wiki_stepslib.php, function after_execute():

          Original
          $this->add_related_files('mod_wiki', 'attachments', 'wiki_page');
          is
          $this->add_related_files('mod_wiki', 'attachments', 'wiki_subwiki');
          isn't?

          Show
          Tatsuya Shirai added a comment - And, in mod/wiki/backup/moodle2/restore_wiki_stepslib.php, function after_execute(): Original $this->add_related_files('mod_wiki', 'attachments', 'wiki_page'); is $this->add_related_files('mod_wiki', 'attachments', 'wiki_subwiki'); isn't?
          Hide
          Tatsuya Shirai added a comment -

          and final. in mod/wiki/backup/moodle2/restore_wiki_stepslib.php, function process_wiki_subwiki():

          Original
          $this->set_mapping('wiki_subwiki', $oldid, $newitemid);
          is
          $this->set_mapping('wiki_subwiki', $oldid, $newitemid, true);
          isn't?

          After modification these three codes, I succeed in restoring all files(attachments, files tab) from backupfile.

          Show
          Tatsuya Shirai added a comment - and final. in mod/wiki/backup/moodle2/restore_wiki_stepslib.php, function process_wiki_subwiki(): Original $this->set_mapping('wiki_subwiki', $oldid, $newitemid); is $this->set_mapping('wiki_subwiki', $oldid, $newitemid, true); isn't? After modification these three codes, I succeed in restoring all files(attachments, files tab) from backupfile.
          Hide
          Marina Glancy added a comment - - edited

          Submitting for integration patch from Tatsuya Shirai that I reviewed and tested. Thanks a lot!

          Show
          Marina Glancy added a comment - - edited Submitting for integration patch from Tatsuya Shirai that I reviewed and tested. Thanks a lot!
          Hide
          CiBoT added a comment -

          Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

          Show
          CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (25, 26 and master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (25, 26 and master), thanks!
          Hide
          Frédéric Massart added a comment -

          Passing, thanks!

          Show
          Frédéric Massart added a comment - Passing, thanks!
          Hide
          Marina Glancy added a comment -

          Thanks for your hard work. Your code is now part of Moodle.

          Show
          Marina Glancy added a comment - Thanks for your hard work. Your code is now part of Moodle.

            People

            • Votes:
              10 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: