Course restore from Moodle v3.4.6 to v3.6.3 error/unknown_context_mapping
Submitted by chuckyang on Tue, 04/16/2019 - 19:11
Forums:
H5P version 1.17.2 with all library updated.
attempting to restore a Moodle v3.4.6+ course with H5P activity(Interactive video) to a Moodle v3.6.3 would result "error/unknown_context_mapping"
Steps to reproduce the error:
- Add an h5p activity to a moodle 3.4 course.
- Backup the moodle 3.4 course.
- Restore into a moodle 3.6 course.
- The backup will fail with an error/unknown_context_mapping error.
On screen debug output on screen from Moodle v3.6 is attached in the post.
nadavkav
Wed, 07/24/2019 - 14:19
Permalink
I am experiancing the same
I am experiancing the same issue
(And it was also reported here:
https://h5p.org/node/488557
https://tracker.moodle.org/browse/MDL-65361 )
asafo
Wed, 08/21/2019 - 11:35
Permalink
Same here, here's a little work around
This happens when for some reason, in mdl_context the first line id is not 1. (The context line of the site itself)
We were able to get around this currently by editing: mod/hvp/backup/moodle2/restore_hvp_stepslib.php
in function after_execute() line 291
replacing:
$this->add_related_files('mod_hvp', 'libraries', null, $context->id);
with:$this->add_related_files('mod_hvp', 'libraries', null, 1);This will only work when the origin site had his id set to one (mdl_context.id)we need to really pass the old context id, I currently don't know how to do this Thanks
ramf
Wed, 09/30/2020 - 10:12
Permalink
Can you please explain where should I change the file?
Hi,
Can you please explain where should I change the file?
Is it on the original server or the server of the moodle that should get the file?
Regards,
kiril
Fri, 11/29/2019 - 17:47
Permalink
I have the same issue with different error
When i restore activity on Moodle 3.73 i got error in the same function. But diferent type of error.
Unknown exception related to local files (Invalid file path
ramf
Wed, 09/30/2020 - 10:10
Permalink
Same when I try from 3.9 to 3.8
Hi,
I get an error: error/unknown_context_mapping when I restoring a course from moodle version 3.9 to 3.8.3.
What can be done?
Regards,
Ram
rmups
Wed, 04/05/2023 - 17:25
Permalink
I have the same issue. Is
I have the same issue. Is there any workaround?
andrey-b
Wed, 04/26/2023 - 17:02
Permalink
A workaround for a similar issue
I have the same issue and I did a temporary workaround for it.
My context:
Both Databases are on MariaDb-Galera-cluster with autoincrement = 3. The restore on Moodle 3.9 was failing with:
Error code: unknown_context_mapping$a contents: error×Stack trace: line 925 of /backup/util/dbops/restore_dbops.class.php: restore_dbops_exception thrownline 239 of /backup/util/plan/restore_structure_step.class.php: call to restore_dbops::send_files_to_pool()line 291 of /mod/hvp/backup/moodle2/restore_hvp_stepslib.php: call to restore_structure_step->add_related_files('mod_hvp', 'libraries', null, $context->id: 2)line 409 of /backup/util/plan/restore_structure_step.class.php: call to restore_hvp_libraries_structure_step->after_execute()line 113 of /backup/util/plan/restore_structure_step.class.php: call to restore_structure_step->launch_after_execute_methods()line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()line 210 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()line 191 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()line 394 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()line 219 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 143 of /backup/restore.php: call to restore_ui->execute()Analysis:
in file
moodle/backup/util/dbops/restore_dbops.class.php
: in methodpublic static function send_files_to_pool
(near line 9xx) replace:if (!$newcontextrecord || !$newcontextrecord->newitemid) {
throw new restore_dbops_exception('unknown_context_mapping', $oldcontextid); // <<<------- this line
}
with the following code:
if (!$newcontextrecord || !$newcontextrecord->newitemid) {
if ($oldcontextid == 2) {
$newcontextrecord = self::get_backup_ids_record($restoreid, 'context', 1);
if (!$newcontextrecord || !$newcontextrecord->newitemid) {
throw new restore_dbops_exception('unknown_context_mapping', 1);
}
} else {
throw new restore_dbops_exception('unknown_context_mapping', $oldcontextid);
}
}
It worked for my case.