Merge branch 'MDL-29877_bad_grade_item_24' of git://github.com/andyjdavis/moodle into MOODLE_24_STABLE
Conflicts: version.php
This commit is contained in:
@@ -1687,5 +1687,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2012120303.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120301.18) {
|
||||
// MDL-29877 Some bad restores created grade items with no category information.
|
||||
$sql = "UPDATE mdl_grade_items
|
||||
SET categoryid = courseid
|
||||
WHERE itemtype <> 'course' and itemtype <> 'category'
|
||||
AND categoryid IS NULL";
|
||||
$DB->execute($sql);
|
||||
upgrade_main_savepoint(true, 2012120301.18);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1154,13 +1154,17 @@ class grade_category extends grade_object {
|
||||
|
||||
} else {
|
||||
$categoryid = $item->categoryid;
|
||||
if (empty($categoryid)) {
|
||||
debugging('Found a grade item that isnt in a category');
|
||||
}
|
||||
}
|
||||
|
||||
// prevent problems with duplicate sortorders in db
|
||||
$sortorder = $item->sortorder;
|
||||
|
||||
while (array_key_exists($sortorder, $cats[$categoryid]->children)) {
|
||||
//debugging("$sortorder exists in item loop");
|
||||
while (array_key_exists($categoryid, $cats)
|
||||
&& array_key_exists($sortorder, $cats[$categoryid]->children)) {
|
||||
|
||||
$sortorder++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user