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

Error in Behat-Test when calling reset_course_userdata()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.1.10, 4.1.11, 4.5
    • Course, Grading methods
    • None
    • MOODLE_401_STABLE, MOODLE_405_STABLE

      I created a Behat test for my plugin. In the Behat test I create a course using the following command:

       

          And the following "courses" exist:           # behat_data_generators::the_following_entities_exist()
            | fullname | shortname | category | enablecompletion |
            | Course 1 | C1        | 0        | 1                | 

      Later I run:

          And I trigger cron                                                   # behat_general::i_trigger_cron()
            Other backtraces found:
            line 1576 of /lib/gradelib.php: call to behat_error_handler()
            line 5711 of /lib/moodlelib.php: call to grade_course_reset()
            line 40 of /local/mscoursereset/classes/task/cron_task.php: call to reset_course_userdata()
            line 263 of /lib/cronlib.php: call to local_mscoursereset()
            line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
            line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
            line 81 of /admin/cron.php: call to cron_run() (Exception) 

      Following the backtrace I finally figured out that on https://github.com/moodle/moodle/blob/e8d03fdae4ec30a40cdc535c8e9e95f30604ec10/lib/gradelib.php#L1575 the "fetch_all" function returns a boolean value. Following this, on https://github.com/moodle/moodle/blob/e8d03fdae4ec30a40cdc535c8e9e95f30604ec10/lib/gradelib.php#L1576 it tries to do a foreach on $grade_items which is a boolean value which finally results in the error I see above.

      I also checked the same for the current Moodle version (4.5dev) which is exactly the issue, see https://github.com/moodle/moodle/blob/7b9a4eeca51b3b5ed0d9813842cfff48b5968ab1/lib/gradelib.php#L1590.

      For me it looks like the case where "$grade_items" becomes boolean isn't catched here.

       

            Unassigned Unassigned
            mstimvol Tim Volckmann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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