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

coursecat->delete_move() relies on move_courses() but doesn't include course/lib.php

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.2.5, 3.3.2
    • 3.1.7, 3.2.4, 3.3.1
    • Course
    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE
    • MOODLE_32_STABLE, MOODLE_33_STABLE
    • master-MDL-59799
    • Hide

      The bug is not triggered by the coursecat PHPUnit test because the test indirectly includes the course/lib.php via the testing_data_generator->create_course() method.

      1. Create a new course category
      2. Create a course within this category
      3. Create a PHP script (coursecat_delete_move.php) inside the Moodle root directory with the following content:

      <?php
      require_once('config.php');
      require_once($CFG->libdir . '/coursecatlib.php');
      $coursecatid = required_param('coursecatid', PARAM_INT);
      $moveto = required_param('moveto', PARAM_INT);
      $coursecat = coursecat::get($coursecatid);
      $coursecat->delete_move($moveto);
      

      1. Run the script either from CLI or open in a browser
      2. Expected: The course category should be deleted and the course should be moved to the given category
      3. Actually: An error message is displayed: "Call to undefined function move_courses()"
      4. With the patch applied the expected behaviour should actually happen
      Show
      The bug is not triggered by the coursecat PHPUnit test because the test indirectly includes the course/lib.php via the testing_data_generator->create_course() method. Create a new course category Create a course within this category Create a PHP script (coursecat_delete_move.php) inside the Moodle root directory with the following content: <?php require_once( 'config.php' ); require_once($CFG->libdir . '/coursecatlib.php' ); $coursecatid = required_param( 'coursecatid' , PARAM_INT); $moveto = required_param( 'moveto' , PARAM_INT); $coursecat = coursecat::get($coursecatid); $coursecat->delete_move($moveto); Run the script either from CLI or open in a browser Expected: The course category should be deleted and the course should be moved to the given category Actually: An error message is displayed: "Call to undefined function move_courses()" With the patch applied the expected behaviour should actually happen

      The method delete_move of the coursecat class uses the move_courses function defined in course/lib.php but does not include this file. This leads to the error "Call to undefined function move_courses() in moodle/lib/coursecatlib.php" if the course/lib.php was not included otherwise before call the delete_move method.

            jojoob Johannes Burk
            jojoob Johannes Burk
            Ankit Agarwal Ankit Agarwal
            David Monllaó David Monllaó
            Simey Lameze Simey Lameze
            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.