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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.7, 3.2.4, 3.3.1
    • Fix Version/s: 3.2.5, 3.3.2
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      master-MDL-59799

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Sep/17