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

codingerror in Global Search when "search within enrolled courses only" is set

    XMLWordPrintable

Details

    • MOODLE_35_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • Hide
      1. Log in as admin
      2. Go to Site administration > Advanced features, enable Global search and save.
      3. Go to Site administration > Plugins > Search > Manage global search
      4. Set Searchable courses field to Search within enrolled courses only if not set.
      5. Add a new course
      6. From the cog menu click Permissions
      7. Enter "moodle/course:view" in the Filter field
      8. For the View courses without participation capability, in Roles with permission press the Allow button and click on Authenticated user
      9. Create a new user
      10. Log in as the new user and go to the course created on step 5.
      11. In the Search box in the header enter "bar" and press Enter
      12. In the Search > Search within field select "Course: [Coursename]"
      13. Press Search
      14. Confirm you don't get a DML exception
      Show
      Log in as admin Go to Site administration > Advanced features, enable Global search and save. Go to Site administration > Plugins > Search > Manage global search Set Searchable courses field to Search within enrolled courses only if not set. Add a new course From the cog menu click Permissions Enter "moodle/course:view" in the Filter field For the View courses without participation capability, in Roles with permission press the Allow button and click on Authenticated user Create a new user Log in as the new user and go to the course created on step 5. In the Search box in the header enter "bar" and press Enter In the Search > Search within field select "Course: [Coursename] " Press Search Confirm you don't get a DML exception

    Description

      Steps to recreate -

      • enable global search on Moodle with all settings left as default
      • create a new course "veggies" and a label "cabbage"
      • give the course:view permission to "Authenticated users" for "veggies"
      • log in as a non-admin user, not registered on any courses
      • go into the "veggies" course and search for "cabbage" - no results, as expected, because "searchable courses" is still set to the default of "search within enrolled courses only"
      • from the "search within" drop-down menu choose "course: veggies" and search again

      Result -

      Coding error detected, it must be fixed by a programmer: moodle_database::get_in_or_equal() does not accept empty arrays

      Stack trace:

      • line 770 of /lib/dml/moodle_database.php: coding_exception thrown
      • line 593 of /search/classes/manager.php: call to moodle_database->get_in_or_equal()
      • line 778 of /search/classes/manager.php: call to core_search\manager->get_areas_user_accesses()
      • line 684 of /search/classes/manager.php: call to core_search\manager->search()
      • line 150 of /search/index.php: call to core_search\manager->paged_search()

      The error doesn't occur if you've changed "searchable courses" to "search within all courses the user can access"
       

      Attachments

        1. image-2019-11-06-13-31-43-524.png
          23 kB
          Rito Corneille
        2. image-2020-12-09-10-46-25-381.png
          19 kB
          Janelle Barcega
        3. MDL-62707 confirmation.png
          28 kB
          Simey Lameze
        4. MDL-62707 DML error.png
          65 kB
          Simey Lameze

        Issue Links

          Activity

            People

              pholden Paul Holden
              mjr66 Mat Ridley
              Simey Lameze Simey Lameze
              Andrew Lyons Andrew Lyons
              Janelle Barcega Janelle Barcega
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Clockify

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