Skip to content

Commit

Permalink
Merge branch 'MDL-76509-400' of https://github.com/safatshahin/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
andrewnicols committed Dec 13, 2022
2 parents 8a4a9fc + 26ed262 commit ff72ae1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/db/upgrade.php
Expand Up @@ -4048,10 +4048,16 @@ function xmldb_main_upgrade($oldversion) {
$runinsert = function (int $lastslot, array $tagstrings) use ($DB) {
$conditiondata = $DB->get_field('question_set_references', 'filtercondition',
['itemid' => $lastslot, 'component' => 'mod_quiz', 'questionarea' => 'slot']);
$condition = json_decode($conditiondata);
$condition->tags = $tagstrings;
$DB->set_field('question_set_references', 'filtercondition', json_encode($condition),
['itemid' => $lastslot, 'component' => 'mod_quiz', 'questionarea' => 'slot']);

// It is possible to have leftover tags in the database, without a corresponding
// slot, because of an old bugs (e.g. MDL-76193). Therefore, if the slot is not found,
// we can safely discard these tags.
if (!empty($conditiondata)) {
$condition = json_decode($conditiondata);
$condition->tags = $tagstrings;
$DB->set_field('question_set_references', 'filtercondition', json_encode($condition),
['itemid' => $lastslot, 'component' => 'mod_quiz', 'questionarea' => 'slot']);
}
};

foreach ($slottags as $tag) {
Expand Down

0 comments on commit ff72ae1

Please sign in to comment.