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

Error when viewing a category while another user is deleting courses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.6, 3.5.3, 3.6.1
    • Fix Version/s: 3.8.4
    • Component/s: Caching, Course
    • Labels:
    • Testing Instructions:
      Hide

      Unit tests cover the change to core_course_category::get_courses

      Setup

      1. Apply MDL-64427-testing.diff to your Moodle instance,
      2. In Site administration > Development > Debugging set the debugging level to DEVELOPER
      3. In Site administration > Development > Make test course Create a course with the following properties:
        • Size of course: M (~100MB; create in ~2minutes)
        • Course short name: C1
        • Course full name: Course 1
        • Course summary: This is a course for testing MDL-64427
      4. In Site administration > Courses > Manage courses and categories create a category (Cat 1)
        • Make a note of the id of the new category in the browser
      5. Move Course 1 into Cat 1
      6. Create a course (Course 2) inside of Cat 1
      7. Create a user that has no special capabilities or enrolments (User 1)

      Test

      1. As an admin, navigate to the category management page for Cat 1 (Site administration > Courses > Manage courses and categories) - Browser A
      2. In a different browser (Browser B) and as User 1, go to /course/index.php?categoryid=x (x = id of Cat 1)
      3. In Browser A delete Course 1
      4. Start refreshing the page in Browser B
        NOTE: This will take a considerable amount of time (on my computer 10-20 minutes)

      Expected results

      • You should observe that initially Course 1 is still present
        • You may observe an Invalid course module ID error if you do:
          1. Make a note of the value below the line containing [array ( in the debugging info section
          2. On the next refresh the error should not be present, or the value from the previous step should have changed.
      • Course 1 should stop appearing for around 30 seconds before the deletion completes in Browser A
        • At this point no errors should be observed
      • Course 2 should continue to be displayed (on non-error pages)
      Show
      Unit tests cover the change to core_course_category::get_courses Setup Apply MDL-64427 -testing.diff to your Moodle instance, In Site administration > Development > Debugging set the debugging level to DEVELOPER In Site administration > Development > Make test course Create a course with the following properties: Size of course: M (~100MB; create in ~2minutes) Course short name: C1 Course full name: Course 1 Course summary: This is a course for testing MDL-64427 In Site administration > Courses > Manage courses and categories create a category ( Cat 1 ) Make a note of the id of the new category in the browser Move Course 1 into Cat 1 Create a course ( Course 2 ) inside of Cat 1 Create a user that has no special capabilities or enrolments ( User 1 ) Test As an admin , navigate to the category management page for Cat 1 ( Site administration > Courses > Manage courses and categories ) - Browser A In a different browser ( Browser B ) and as User 1 , go to /course/index.php?categoryid=x ( x = id of Cat 1 ) In Browser A delete Course 1 Start refreshing the page in Browser B NOTE: This will take a considerable amount of time (on my computer 10-20 minutes) Expected results You should observe that initially Course 1 is still present You may observe an Invalid course module ID error if you do: Make a note of the value below the line containing [array ( in the debugging info section On the next refresh the error should not be present, or the value from the previous step should have changed. Course 1 should stop appearing for around 30 seconds before the deletion completes in Browser A At this point no errors should be observed Course 2 should continue to be displayed (on non-error pages)
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull from Repository:
    • Pull 3.7 Branch:
      MDL-64427-m37
    • Pull 3.8 Branch:
      MDL-64427-m38
    • Pull Master Branch:

      Description

      We have recently encountered an error while viewing course categories while two users are deleting courses in it.

      TypeError: Uncaught exception 'TypeError' with message 'Argument 1 passed to course_in_list::__construct() must be an instance of stdClass, null given, called in /var/www/html/lib/coursecatlib.php on line 1585' in /var/www/html/lib/coursecatlib.php:2896
      in course_in_list::__construct called at /var/www/html/lib/coursecatlib.php (1585)
      in coursecat::get_courses called at /var/www/html/course/classes/management_renderer.php (534)
      in core_course_management_renderer::course_listing called at /var/www/html/course/management.php (498)
      

      It looks as though it occurs because there is a loop in the get_courses() method that loops through all the entries from the coursecat cache and then assumes that a database query will return a record for each course in the cache.

      It looks as though this could occur in master as well.

        Attachments

        1. error_screencast.mp4
          2.94 MB
        2. image-2019-01-16-15-30-03-401.png
          image-2019-01-16-15-30-03-401.png
          184 kB
        3. MDL-64427-testing.diff
          0.5 kB
        4. screenshot-1.png
          screenshot-1.png
          80 kB

          Activity

            People

            Assignee:
            nmagill Neill Magill
            Reporter:
            nmagill Neill Magill
            Peer reviewer:
            Tim Hunt
            Integrator:
            Andrew Nicols
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              13/Jul/20

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 17 minutes
                2h 17m