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

SQL error due to undocumented behaviour change in sort parameter

XMLWordPrintable

    • 1
    • Team Hedgehog 2024 Review 4, Team Hedgehog 2024 Sprint 4.1

      The argument `sort` to the core_user\table\participants_search::get_participants method used to require the "ORDER BY" statement, since MDL-78030 it can no longer contain it or it causes an SQL error. This issue may affect other arguments too.

      Proof by unit test

      Add the following snippet to user/tests/table/participants_search_test.php.

      public function test_sort() {
          $course = $this->getDataGenerator()->create_course();
          $coursecontext = context_course::instance($course->id);
          $this->create_course_with_users(1, 1, 1, 1);
       
          $filterset = new participants_filterset();
          $search = new participants_search($course, $coursecontext, $filterset);
       
          $rs = $search->get_participants('', [], 'ORDER BY id');
          $rs->close();
      }
      

      Run the tests on 4.4 and 4.5.

      vendor/bin/phpunit user/tests/table/participants_search_test.php
      

      Expected: The tests pass
      Actual: The tests fail with database error on 4.5

      Removing the "ORDER BY" part in the test will cause the test to fail on 4.4.

            meirza.arson@moodle.com Meirza
            fred Frédéric Massart
            Raquel Ortega Raquel Ortega
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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