-
Sub-task
-
Resolution: Won't Fix
-
Major
-
None
-
2.1
-
MOODLE_21_STABLE
-
The temporary staging table M_RESOURCE_OLD is created with a unique index on the OLDID column, into which is inserted the current M_RESOURCE table's ID value. But because the table is being populated with a SELECT from M_RESOURCE joined with M_COURSE_MODULES, there is the likelihood that there will be duplicate resource ID values being inserted into the OLDID column.
For example, an instructor puts the same resource in two or more different sections in the course, for whatever reason. That same resource instance, will be in the M_COURSE_MODULES table, for the same course, but with different sections.
The upgrade routine needs to take into account that with the join, ID value is not guaranteed to be unique in the result set.
In this situation, upgrade is on Oracle, but likely affects all DBs.
Error reported:
Debug info: ORA-00001: unique constraint (MOODLE2.M_RESOOLD_OLD_UIX) violated
INSERT INTO m_resource_old (oldid, course, name, type, reference, intro, introformat, alltext, popup, options, timemodified, cmid)
SELECT r.id, r.course, r.name, r.type, r.reference, r.summary, 0, r.alltext, r.popup, r.options, r.timemodified, cm.id
FROM m_resource r
LEFT JOIN m_course_modules cm ON (r.id = cm.instance AND cm.module = :o_module)
[array (
'o_module' => '15',
)]
Stack trace:
line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 268 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
line 996 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
line 258 of /mod/resource/db/upgradelib.php: call to oci_native_moodle_database->execute()
line 46 of /mod/folder/db/upgradelib.php: call to resource_20_prepare_migration()
line 39 of /mod/folder/db/install.php: call to folder_20_migrate()
line 519 of /lib/upgradelib.php: call to xmldb_folder_install()
line 271 of /lib/upgradelib.php: call to upgrade_plugins_modules()
line 1466 of /lib/upgradelib.php: call to upgrade_plugins()
line 317 of /admin/index.php: call to upgrade_noncore()