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

Error in availability code when importing activity from old course using PHP8.0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.11.8, 4.0.2
    • 3.11.6, 3.11.7, 4.0.1
    • Other
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • Hide

      Requirements

      • Web server running php 8.0.x
      • Repeat the before/after steps below with 311, 400 and master.

      Before the patch

      • Restore (admin -> courses -> restore course) the attached course backup into a new course. Don't change any setting.
      • Verify that you get the error "Exception - array_values(): Argument #1 ($array) must be of type array, null given" (in the web page or in the web server logs).
      • Go to the "Site home" (front page). Click in the jus restored course (surely its name will be "Course A - MDL-74358 copy 1"
      • Verify that you can see the "A page with restrictions" resource and it shows 2 restrictions.
      • Verify that the first restriction is "It's on or after 12 June 2021, 11 pm".
      • Verify that the second restriction is "You belong to a group in (Missing grouping)"

      After the patch

      • Restore (admin -> courses -> restore course) the attached course backup into a new course. Don't change any setting.
      • Verify that the process ends ok, without any error. The "The course was restored successfully" on green background should be shown.
      • Go to the "Site home" (front page). Click in the jus restored course (surely its name will be "Course A - MDL-74358 copy 2"
      • Verify that you can see the "A page with restrictions" resource and it shows 1 restriction only.
      • Verify that the first restriction is "It's on or after 12 June 2021, 11 pm".
      • Verify that there isn't any "grouping" second restriction.
      Show
      Requirements Web server running php 8.0.x Repeat the before/after steps below with 311, 400 and master. Before the patch Restore (admin -> courses -> restore course) the attached course backup into a new course. Don't change any setting. Verify that you get the error " Exception - array_values(): Argument #1 ($array) must be of type array, null given " (in the web page or in the web server logs). Go to the "Site home" (front page). Click in the jus restored course (surely its name will be "Course A - MDL-74358 copy 1" Verify that you can see the "A page with restrictions" resource and it shows 2 restrictions. Verify that the first restriction is "It's on or after 12 June 2021, 11 pm". Verify that the second restriction is "You belong to a group in (Missing grouping)" After the patch Restore (admin -> courses -> restore course) the attached course backup into a new course. Don't change any setting. Verify that the process ends ok, without any error. The "The course was restored successfully" on green background should be shown. Go to the "Site home" (front page). Click in the jus restored course (surely its name will be "Course A - MDL-74358 copy 2" Verify that you can see the "A page with restrictions" resource and it shows 1 restriction only. Verify that the first restriction is "It's on or after 12 June 2021, 11 pm". Verify that there isn't any "grouping" second restriction.

      On build 20220315:

      Attempt to import an activity from one course to another.

      Traceback:

      [30-Mar-2022 11:02:58 Pacific/Auckland] Default exception handler: Exception - array_values(): Argument #1 ($array) must be of type array, null given Debug:
      Error code: generalexceptionmessage

      • line 687 of /availability/classes/tree.php: TypeError thrown
      • line 687 of /availability/classes/tree.php: call to array_values()
      • line 323 of /availability/classes/info.php: call to core_availability\tree->update_after_restore()
      • line 926 of /backup/moodle2/restore_stepslib.php: call to core_availability\info->update_after_restore()
      • line 34 of /backup/util/plan/restore_execution_step.class.php: call to restore_update_availability->define_execution()
      • line 181 of /backup/util/plan/base_task.class.php: call to restore_execution_step->execute()
      • line 191 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
      • line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      • line 394 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      • line 193 of /backup/import.php: call to restore_controller->execute_plan()

      It seems this must be a bug rather than "just" duff data, as core_availability\info->update_after_restore() has just created a new tree, which uses decode_availability, which is supposed to either discard invalid data or throw an exception.

      Attempting to replicate the problem on a dev instance, backing up and then restoring the course did complete successfully. Restoring the same backup onto the original prod instance did not succeed.

        1. backup-MDL-74358-nu.mbz
          5 kB
        2. MDL-74358_after_1.png
          MDL-74358_after_1.png
          73 kB
        3. MDL-74358_after_2.png
          MDL-74358_after_2.png
          73 kB
        4. MDL-74358_before_1.png
          MDL-74358_before_1.png
          134 kB
        5. MDL-74358_before_2.png
          MDL-74358_before_2.png
          77 kB

            stronk7 Eloy Lafuente (stronk7)
            nwpotago Nick Phillips
            Sam Marshall Sam Marshall
            Jun Pataleta Jun Pataleta
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 20 minutes
                3h 20m

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