if ($oldversion < 2022020200.02) {
// Next, split question records into the new tables.
upgrade_migrate_question_table();
// Main savepoint reached.
upgrade_main_savepoint(true, 2022020200.02);
}
And in this function where it goes wrong in /lib/db/upgradelib.php:
/**
* Split question table in 2 new tables:
*
* question_bank_entries
* question_versions
*
* Move the random questions records to the following table:
* question_set_reference
*
* Move the question related records from quiz_slots table to:
* question_reference
*
* Move the tag related data from quiz_slot_tags to:
* question_references
*
* For more information: https://moodle.org/mod/forum/discuss.php?d=417599#p1688163
*/
function upgrade_migrate_question_table(): void {
global $DB;
// Maximum size of array.
$maxlength = 30000;
// Array of question_versions objects.
$questionversions = [];
// Array of question_set_references objects.
$questionsetreferences = [];
// The actual update/insert done with multiple DB access, so we do it in a transaction.
$transaction = $DB->start_delegated_transaction(); <= this is the line where the error happens <=