I found this bug when restoring a backup from
The grades went into db ok, I checked it immediately after the restore. However grade_regrade_final_grades() seem to have cleaned the grade_grades in category and course gradeitem. Then I got ERROR in all categories and course gradeitem. I did a bit of look up and found a few things
1) When looping the gradeitems, some gradeitem in dependson array is referencing itself
2) Categories with forumla do not include related gradeitems
3) Categories with forumla are getting invalid token '[' from EvalMath
Can you please take a look? If you don't have time I will look at it next week.