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

Question statistics occasional errors Call to a member function populate_from_record() on null

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-79332_401
    • Hide

      I can't think of a convincing way to test that the fix correctly handles bad data, because the bad data is really a 'this should never happen' situation.

      The important thing to test is that this change does not cause any regressions, and the automated tests will do this for us, courtesy of CiBoT.

      Show
      I can't think of a convincing way to test that the fix correctly handles bad data, because the bad data is really a 'this should never happen' situation. The important thing to test is that this change does not cause any regressions, and the automated tests will do this for us, courtesy of CiBoT.

      The way things are supposed to work, there should never be statistics calculated for non-question questions like descriptions.

      However, in the past, we had bugs where that did happen (e.g. MDL-77381 is related, but not the exact one).

      In the case where you have some old stats analysis in the database, pointing at the wrong sore of question, this leads to a fatal error:

      Exception - Call to a member function populate_from_record() on null
       
      Stack trace:
          line 214 of /question/classes/statistics/questions/all_calculated_for_qubaid_condition.php: Error thrown
          line 492 of /question/classes/statistics/questions/calculator.php: call to core_question\statistics\questions\all_calculated_for_qubaid_condition->get_cached()
          line 669 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->get_cached()
          line 159 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysi
      

      The code needs to be robust to this.

      (If this does not cause a fatal error, you can go to the statistics report in the problem quiz, and click the 'Recalculate' button. However, with this fatal error, you can't get to the button.)

      This can also happen with the variant stats 'e.g. for calcuated questions. So we need the same changes there too.

      Anyway, this is affecting us, so I am going to change the code to be more robust.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Anupama Sarjoshi Anupama Sarjoshi
            Huong Nguyen Huong Nguyen
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 31 minutes
                1h 31m

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