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

Disabling cachejs can break language string loading

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-77023-400
    • MDL-77023-401
    • Hide
      1. Edit site config.php, adding the following:

        $CFG->cachejs = false;
        

      2. Apply the following patch:

        $ git diff
        diff --git a/my/index.php b/my/index.php
        index a620fad..8d06695 100644
        --- a/my/index.php
        +++ b/my/index.php
        @@ -101,6 +101,11 @@ $PAGE->set_subpage($currentpage->id);
         $PAGE->set_title($pagetitle);
         $PAGE->set_heading($pagetitle);
         
        +$PAGE->requires->js_amd_inline("require(['core/str'], str => {
        +    str.get_string('accept', 'core').then(accept => window.alert(accept));
        +    str.get_string('accept').then(accept => window.alert(accept));
        +});");
        +
         if (!isguestuser()) {   // Skip default home page for guests
             if (get_home_page() != HOMEPAGE_MY) {
                 if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
        

      3. Navigate to dashboard
      4. Press Purge caches
      5. Confirm you see two alerts containing the text "Accept"
      Show
      Edit site config.php , adding the following: $CFG->cachejs = false; Apply the following patch: $ git diff diff --git a/my/index.php b/my/index.php index a620fad..8d06695 100644 --- a/my/index.php +++ b/my/index.php @@ -101,6 +101,11 @@ $PAGE->set_subpage($currentpage->id); $PAGE->set_title($pagetitle); $PAGE->set_heading($pagetitle); +$PAGE->requires->js_amd_inline("require(['core/str'], str => { + str.get_string('accept', 'core').then(accept => window.alert(accept)); + str.get_string('accept').then(accept => window.alert(accept)); +});"); + if (!isguestuser()) { // Skip default home page for guests if (get_home_page() != HOMEPAGE_MY) { if (optional_param('setdefaulthome', false, PARAM_BOOL)) { Navigate to dashboard Press Purge caches Confirm you see two alerts containing the text "Accept"

    Description

      If $CFG->cachejs = false; is set, then attempting to load language strings without specifying the component property can result in unresolved lang strings such as the following:

      See also MDL-68528 for history on normalizing component variable in JS lang strings

      This is apparently a recurring problem in Workplace (see WP-4033 & WP-2678), and I'm fairly sure is what is being described in MDL-65611

      Attachments

        1. screenshot-1.png
          screenshot-1.png
          31 kB
        2. master.gif
          master.gif
          295 kB
        3. 401.gif
          401.gif
          376 kB
        4. 400.gif
          400.gif
          287 kB

        Issue Links

          Activity

            People

              pholden Paul Holden
              pholden Paul Holden
              David Carrillo David Carrillo
              Andrew Lyons Andrew Lyons
              Ron Carl Alfon Yu Ron Carl Alfon Yu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13/Mar/23

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 1 minute
                  4h 1m