Skip to content

Commit

Permalink
GH-723 Fix for empty oldcontextid
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszkiba committed Jan 24, 2025
1 parent 57fb474 commit eefce73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classes/catquiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,9 @@ function ($param) use ($newcontextid) {
// Create a mapping of questionid -> item.
// If it exists in both old and new context, the mapping maps to the new context.
$qid2item = [];
$contextids = array_reverse(range($oldcontextid, $newcontextid));
$contextids = $oldcontextid
? array_reverse(range($oldcontextid, $newcontextid))
: [$newcontextid];
[$insql, $inparams] = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'contextid');
foreach ($DB->get_records_select('local_catquiz_items', "contextid $insql", $inparams) as $i) {
if (!isset($qid2item[$i->componentid]) || $i->contextid > $qid2item[$i->componentid]->contextid) {
Expand Down

0 comments on commit eefce73

Please sign in to comment.