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

Category list caching breaks multilang category names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.7.4, 2.8.2
    • 2.6.5, 2.7.2
    • Course
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MDL-48036-master
    • Hide
      • Install additional language
      • Create some categories with multilang names, like:
        <span lang="fi" class="multilang">Test-FI</span><span lang="sv" class="multilang">Test-SV</span><span lang="en" class="multilang">Test-EN</span>
      • In Site administration > Plugins > Filters > Manage filters, activate Multi-Language Content, apply to content and headings
      • Go to /course/index.php?categoryid=1 and make sure that "Course categories" dropdown is populated in the current language
      • Change the interface language and make sure the dropdown is populated with the names in the new current language
      Show
      Install additional language Create some categories with multilang names, like: <span lang="fi" class="multilang">Test-FI</span><span lang="sv" class="multilang">Test-SV</span><span lang="en" class="multilang">Test-EN</span> In Site administration > Plugins > Filters > Manage filters, activate Multi-Language Content, apply to content and headings Go to /course/index.php?categoryid=1 and make sure that "Course categories" dropdown is populated in the current language Change the interface language and make sure the dropdown is populated with the names in the new current language

      We have category names as multilang strings in 3 different languages.
      We noticed that when requesting a new course through course/request.php, the language of the course category names stay the same even when a different language is selected.
      We found that the category list is actually generated once according to UI language setting at that point in time and then cached for 10 minutes.

      course/request_form.php on line 73 calls coursecat::make_categories_list in lib/coursecatlib.php

      $displaylist = coursecat::make_categories_list();
      

      http://git.moodle.org/gw?p=moodle.git;a=blob;f=course/request_form.php;hb=refs/heads/master#l73

      The bug seems to lie in the way make_categories_list() handles the caching. The multilang filtering is done before caching the category list.

      'name' => format_string($record->name, true, array('context' => $context)),
      

      http://git.moodle.org/gw?p=moodle.git;a=blob;f=lib/coursecatlib.php;hb=refs/heads/master#l2183

      This makes displaying the list of categories in other languages impossible until the cache is emptied after 10 minutes.

      A possible workaround is disable caching by setting $baselist=false in make_categories_list(). Is this kind of caching necessary for performance reasons? If so, could caching be done so that the entire multilang string is cached and format_string applied later on in course/request.php - and everywhere else a call to make_categories_list() is made?

            moodle.com Moodle HQ
            schach Heiko Schach
            Simey Lameze Simey Lameze
            Dan Poltawski Dan Poltawski
            Jetha Chan Jetha Chan
            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.