-
Bug
-
Resolution: Fixed
-
Major
-
3.9
-
MOODLE_39_STABLE
-
MOODLE_38_STABLE
-
MDL-68528-master -
Our JS String function component normalisation does not match what we do in PHP.
In PHP we normalise both "moodle" and an empty string to "core". In JS we do neither.
For the most part this is okay - we have never done this, however we also do not do this for templates.
If you have a template which contains either of the old values, then the template stringHelper function sees it as a required string, it is not normalised in the core/str module, and then we perform a WS call to fetch it. The WS call happens in PHP land where the normalisation does happen.
This leads to a performance issue as strings will be fetched multiple times if the inconsistent components are used.
We have two options:
- normalise the string in core/str; or
- normalise in the template stringHelper.
If we normalise in the string module then this will mean that we have the same API in both PHP and JavaScript, but we will essentially be allowing a deprecated component name to be used in JavaScript where it was never previously allowed.
If we normalise in the template module then we will solve the function for templates, but have an inconsistent API between JS and PHP.
Since the empty string is still typically seen in a number of parts of Moodle and traditionally accepted, we could have a combined approach:
- normalise both moodle and empty string to core in the template module's stringHelper; and
- normalise an empty string to core in the string module.