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

Importing a backup file to an existing course fails when duplicate block contexts are missing

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • 31_mdl75668
    • 40_mdl75668
    • mdl75668
    • Hide
      1. Add the multi-block plugin to your site: https://moodle.org/plugins/block_multiblock
      2. Add the block to a course
        1. Turn editing on
        2. Press add new block
        3. Choose to add a new multiblock block to the course
        4. While viewing the course with the new multiblock, click the "cog" above the multiblock and select "manage multiblock contents"
        5. in the "select block" droplist choose to add "online users" block to the multiblock and press the "add" button
      3. Create a backup file.
        1. On the course homepage, go to the more -> course reuse link in the course header
        2. select the "Backup" option in the drop list at the top
        3. Press the "jump to final step" button at the bottom of the page and press continue when complete.
      4. Restore the backup
        1. On the course homepage, go to the more -> course reuse link in the course header,
        2. Select the "restore" option in the drop list at the top.
        3. your recently created course backup should show at the bottom of the page, click the "restore" link beside this backup you just created.
        4. Press Continue on the confirmation page
        5. On the Destination page, choose the "restore into this course" option and leave the "merge the backup course into this course" option selected and hit continue.
        6. Continue accepting default values on each restore page after this and ensure that the restore process completes and does not show an error message.
      Show
      Add the multi-block plugin to your site: https://moodle.org/plugins/block_multiblock Add the block to a course Turn editing on Press add new block Choose to add a new multiblock block to the course While viewing the course with the new multiblock, click the "cog" above the multiblock and select "manage multiblock contents" in the "select block" droplist choose to add "online users" block to the multiblock and press the "add" button Create a backup file. On the course homepage, go to the more -> course reuse link in the course header select the "Backup" option in the drop list at the top Press the "jump to final step" button at the bottom of the page and press continue when complete. Restore the backup On the course homepage, go to the more -> course reuse link in the course header, Select the "restore" option in the drop list at the top. your recently created course backup should show at the bottom of the page, click the "restore" link beside this backup you just created. Press Continue on the confirmation page On the Destination page, choose the "restore into this course" option and leave the "merge the backup course into this course" option selected and hit continue. Continue accepting default values on each restore page after this and ensure that the restore process completes and does not show an error message.

    Description

      As also described in: https://github.com/catalyst/moodle-block_multiblock/issues/64

      When restoring a backup file into an existing course (merging contents) the block restore class skips duplicate blocks.

      Our multiblock plugin allows for other blocks to sit "inside" a multiblock - so the parent context for these "child" blocks are set to the multi-blocks context id.

      When performing a restore, the restore_block_instance_structure_step::process_block() function checks to see if the block being restored is a duplicate, and if so will skip it.

      But.. then when trying to restore the "child" blocks the process_block checks the child blocks parentcontextid and finds it does not exist (as the multiblock has been skipped) and so it throws an restore_block_missing_parent_ctx exception here causing the restore process to halt:
      https://github.com/moodle/moodle/blob/master/backup/moodle2/restore_stepslib.php#L4242

      We have two options here...
      1) Instead of triggering an exception above, just get that to return false (ignoring the block it's trying to restore)

      2)add in some set_mapping() calls when it finds a duplicate block, saving the existing blocks mapping so that it can be used when handling the child blocks.

      I had a look to see if I could find a way to fix this in the multi-block code, but couldn't find a way to do it there so will drop in a patch based on option 2 above to get some feedback on this.

      Attachments

        1. MDL-75668_master.webm
          3.21 MB
        2. MDL-75668_v311.webm
          2.97 MB
        3. MDL-75668_v400.webm
          3.36 MB

        Activity

          People

            danmarsden Dan Marsden
            danmarsden Dan Marsden
            Peter Burnett Peter Burnett
            Jake Dallimore Jake Dallimore
            Angelia Dela Cruz Angelia Dela Cruz
            Adrian Greeve, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Nov/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h