Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
4.0.3, 4.0.4
-
MOODLE_400_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
31_mdl75668
-
40_mdl75668
-
mdl75668
-
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.