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

Calling $PAGE->requires->xx before require_login() + force language gives javascript language string error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2, 2.3
    • Fix Version/s: 2.3.2
    • Component/s: Other
    • Labels:
    • Testing Instructions:
      Hide

      For developers:
      see description or create a test page with (you need Czech lang pack installed)

      <?php
      require('config.php');
      $PAGE->set_url('/xx.php');
      $PAGE->set_context(null);
      echo $OUTPUT->header();
      $SESSION->lang = 'en';
      $PAGE->requires->string_for_js('course', 'moodle', 1);
      $SESSION->lang = 'cs';
      $PAGE->requires->string_for_js('course', 'moodle', 1);
      echo $OUTPUT->footer();

      Show
      For developers: see description or create a test page with (you need Czech lang pack installed) <?php require('config.php'); $PAGE->set_url('/xx.php'); $PAGE->set_context(null); echo $OUTPUT->header(); $SESSION->lang = 'en'; $PAGE->requires->string_for_js('course', 'moodle', 1); $SESSION->lang = 'cs'; $PAGE->requires->string_for_js('course', 'moodle', 1); echo $OUTPUT->footer();
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w28_MDL-33887_m24_jsstrings

      Description

      If you have a Moodle course with the language forced (e.g. to Deutsch (De)) and the user's own language is set to another language (e.g. to English (En)), then a page with a filepicker element (e.g. the 'Add blog' page of the OU Blog) causes an error.

      This is because the language strings for the filepicker form element javascript (including the 'cancel' string) are loaded before the forced course language is applied, whereas 'init_requirements_data' (also including the 'cancel' string) is called after the force course language is applied. This means that the first one loads, in my case, the English 'Cancel' and the second attempts to load the German 'Abbrechen', causing an exception, as they don't match.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Sep/12