For quite some time we have had trouble with courses not sorting properly in all of our categories however we have had no errors that we could detect and were not able to determine what the cause was. While running our enrollment sync against an external database, we have discovered an error (there are several hundred exactly like the sample one below – see attached file for all errors). The course id's match the courses that are out of order within the course categories.
This has been happening since we have been on 1.9.x (we are currently running 1.9.9).
This does appear related to MDL-21730.
Is there a way for us to refresh or correct the sort order fields in the problematic courses (or even in all of them) to resolve this issue?
-------------- sample error ----------------
PHP Notice: Duplicate entry '12-4294967295' for key 2<br /><br />UPDATE mdl_course SET sortorder = '4294968296' WHERE id = '2557'<ul style="text-align: left"><li>line 1328 of lib/dmllib.php: call to debugging()</li><li>line 1254 of lib/dmllib.php: call to set_field_select()</li><li>line 1385 of lib/datalib.php: call to set_field()</li><li>line 1411 of lib/datalib.php: call to fix_course_sortorder()</li><li>line 195 of enrol/database/enrol.php: call to fix_course_sortorder()</li><li>line 34 of enrol/database/enrol_database_sync.php: call to enrolment_plugin_database->sync_enrolments()</li></ul> in /path/to/moodle/lib/weblib.php on line 7005
PHP Notice: Duplicate entry '12-4294967295' for key 2<br /><br />UPDATE mdl_course
SET sortorder=sortorder+8589937600
WHERE category=12<ul style="text-align: left"><li>line 103 of lib/dmllib.php: call to debugging()</li><li>line 1376 of lib/datalib.php: call to execute_sql()</li><li>line 1396 of lib/datalib.php: call to fix_course_sortorder()</li><li>line 1411 of lib/datalib.php: call to fix_course_sortorder()</li><li>line 195 of enrol/database/enrol.php: call to fix_course_sortorder()</li><li>line 34 of enrol/database/enrol_database_sync.php: call to enrolment_plugin_database->sync_enrolments()</li></ul> in /path/to/moodle/lib/weblib.php on line 7005