MDL-86798 questions: Check original context is on the same site
When checking if the original context exists during a restore, we need to check that we're looking at the context on the same site, not one on a different site that happens to have the same ID.
This commit is contained in:
@@ -5555,7 +5555,11 @@ class restore_move_module_questions_categories extends restore_execution_step {
|
||||
// but if that context still exists on the site and the user has access then point question references
|
||||
// to the originals.
|
||||
$originalcontext = context::instance_by_id($contextid, IGNORE_MISSING);
|
||||
if ($originalcontext && has_capability('mod/qbank:view', $originalcontext)) {
|
||||
if (
|
||||
$this->task->is_samesite()
|
||||
&& $originalcontext
|
||||
&& has_capability('mod/qbank:view', $originalcontext)
|
||||
) {
|
||||
$originalquestions = get_questions_category(question_get_top_category($contextid), false);
|
||||
$targetcoursecontext = context_course::instance($this->get_courseid());
|
||||
foreach ($originalquestions as $originalquestion) {
|
||||
|
||||
Reference in New Issue
Block a user