Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74449

Error in gradebook with PHP8.0

XMLWordPrintable

      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?

            stronk7 Eloy Lafuente (stronk7)
            nwpotago Nick Phillips
            Carlos Escobedo Carlos Escobedo
            Victor Déniz Falcón Victor Déniz Falcón
            CiBoT CiBoT
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 50 minutes
                6h 50m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.