-
Bug
-
Resolution: Fixed
-
Major
-
3.11.6, 4.0.1
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
When a grade calculation refers to an item that no longer exists, attempting to access gradebook reports can fail with:
[04-Apr-2022 15:38:44 Pacific/Auckland] PHP Warning: Undefined array key 29981 in /d1/srv/moodle/otagounifom/moodle/lib/grade/grade_grade.php on line 734
[04-Apr-2022 15:38:44 Pacific/Auckland] Default exception handler: Exception - array_merge(): Argument #2 must be of type array, null given Debug:
Error code: generalexceptionmessage
- line 734 of /lib/grade/grade_grade.php: TypeError thrown
- line 734 of /lib/grade/grade_grade.php: call to array_merge()
- line 807 of /lib/grade/grade_grade.php: call to grade_grade::flatten_dependencies_array()
- line 499 of /grade/report/lib.php: call to grade_grade::get_hiding_affected()
- line 219 of /grade/report/overview/lib.php: call to grade_report->blank_hidden_total_and_adjust_bounds()
- line 273 of /grade/report/overview/lib.php: call to grade_report_overview->setup_courses_data()
- line 167 of /grade/report/overview/index.php: call to grade_report_overview->fill_table()
grade_grade class static method flatten_dependencies_array assumes that all grade items depended on will exist; simple fix is a check for array_key_exists around the affected code:
if (array_key_exists($subdepends, $dependson)) {
|
$dependson[$itemid] = array_unique(array_merge($depends, $dependson[$subdepends]));
|
sort($dependson[$itemid], SORT_NUMERIC);
|
}
|
But it may be desirable to throw an error describing the problem instead?