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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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:
    • Testing Instructions:
      Hide

      Unfortunately this does not fix restoring from backups created before the patch because files were not included at all.

      1. Create course with wiki activity, create page with files in it
      2. Backup wiki activity
      3. Restore wiki activity in another course, make sure files are restored
      Show
      Unfortunately this does not fix restoring from backups created before the patch because files were not included at all. Create course with wiki activity, create page with files in it Backup wiki activity Restore wiki activity in another course, make sure files are restored
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull Master Branch:
      wip-MDL-35305-master

      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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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
          shirai 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 Marina Glancy added a comment - - edited

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

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

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

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

          Integrated (25, 26 and master), thanks!

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

          Passing, thanks!

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

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

          Show
          marina 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:
                Fix Release Date:
                12/May/14