Moodle
  1. Moodle
  2. MDL-33441

Choosing 'Combo-list' in the front-settings page with no visible categories causes error.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.9, 2.1, 2.2.3
    • Fix Version/s: 2.1.7, 2.2.4
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide
      1. Log in as admin
      2. Go to Admin > Courses > Add/edit courses
      3. Hide all categories
      4. Go to Admin > Front Page > Front Page settings
      5. In the setting 'frontpage' select 'Combo list' from one of the dropdowns
      6. Log out
      7. Visit front page
      8. Verify that no errors are displayed
      9. Log back in as admin, unhide some categories
      10. Log back out and verify that the categories are dislayed
      Show
      Log in as admin Go to Admin > Courses > Add/edit courses Hide all categories Go to Admin > Front Page > Front Page settings In the setting 'frontpage' select 'Combo list' from one of the dropdowns Log out Visit front page Verify that no errors are displayed Log back in as admin, unhide some categories Log back out and verify that the categories are dislayed
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
    • Rank:
      41331

      Description

      The error -

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

      More information about this error
      Stack trace:

      line 595 of \lib\dml\moodle_database.php: coding_exception thrown
      line 2097 of \course\lib.php: call to moodle_database->get_in_or_equal()
      line 235 of \index.php: call to get_course_category_tree()

      The error happens when the front-page setting is set to 'Combo List' and all categories have been set to hidden, with the user logged in not given the capability to view hidden categories. The array called $categoryids is not being populated with any values because it skips adding the hidden categories, so remains empty. In the code when looping through the categories it checks to see if it is visible, and if it isn't and the user does not have the 'moodle/category:viewhiddencategories' capability then it will not be added to this array. So, in some cases, no categories are ever added which creates the 'does not accept empty arrays' error.

        Activity

        Hide
        Dan Poltawski added a comment -

        Thanks for the report, I've fixed this and submiting for integration.

        Note to integrator/tester, I have chosen to just fix the fatal error and not fix the output to hide collapseall/expandall links when there are no courses. I think that this is sufficient since its pretty rare to have a real used site without any visible categories..

        Show
        Dan Poltawski added a comment - Thanks for the report, I've fixed this and submiting for integration. Note to integrator/tester, I have chosen to just fix the fatal error and not fix the output to hide collapseall/expandall links when there are no courses. I think that this is sufficient since its pretty rare to have a real used site without any visible categories..
        Hide
        Sam Hemelryk added a comment -

        Thanks Dan, changes looked spot on and have been integrated now

        Show
        Sam Hemelryk added a comment - Thanks Dan, changes looked spot on and have been integrated now
        Hide
        Andrew Davis added a comment -

        Works as described in master, 2.2 and 2.1. Passing.

        Show
        Andrew Davis added a comment - Works as described in master, 2.2 and 2.1. Passing.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3.

        Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish.

        Many thanks for your collaboration!

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3. Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish. Many thanks for your collaboration! Ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: