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

Course Category Cache issue

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.1.10, 3.4.1
    • Fix Version/s: None
    • Component/s: Caching, Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_34_STABLE

      Description

      The delete function doesn't always properly clear cache after deletion.

      Was doing a small test for deleting course based on id with a csv.
       

      <?php
      // Require config and userlib.
      require_once('config.php');
      require_once($CFG->dirroot."/user/lib.php");
      require_once($CFG->dirroot."/course/externallib.php");
      require_once($CFG->dirroot."/course/lib.php");
       
      // Set values for deleting users.
      $coursetable = 'course';
      $coursesfile = fopen('test.csv', 'r');
       
      // Get courses.
      $courses = [];
       
      while (!feof($coursesfile) ) {
          $courses[] = fgetcsv($coursesfile);
      }
      fclose($coursesfile);
       
      $list = '';
      foreach ($courses as $course) { $list .= $course[0].', '; }
      $select ="id NOT IN (". $list ."1)";
      $courses_delete = $DB->get_records_select($coursetable, $select);
       
      foreach ($courses_delete as $course) {
          delete_course($course);
      }

      Run this code two times once with 2 course then a second time with 2 different courses.
      It'll cause the following error:

      Exception - Argument 1 passed to course_in_list::__construct() must be an instance of stdClass, null given, called in [dirroot]\lib\coursecatlib.php on line 1559

      After awhile cache will be cleared and the problem solves itself, but this shouldn't be happening in the first place.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            genyaa GeNyaa
            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:
            2 Start watching this issue

              Dates

              Created:
              Updated: