-
Bug
-
Resolution: Unresolved
-
Minor
-
2.4
-
MOODLE_24_STABLE
$PAGE->requires->js(); uses a path relative to $CFG->dirroot to build the path to the script.
If an admin sets $CFG->themedir and a theme in that directory has a javascript file that is called with $PAGE->requires->js() it will return an error that the file cannot be found.
to test the issue do the following:
#) set $CFG->themedir in config.php
#) add a theme to the directory set in $CFG->themedir
#) add a javascript called theme.js to the /javascript/ directory in your theme
#) add the code below to your theme to:
if (!empty($CFG->themedir)) {
|
$themedir = $CFG->themedir;
|
} else {
|
$themedir = $CFG->dirroot . '/theme';
|
}
|
if (file_exists($themedir . '/' . current_theme() . '/javascript/respond.js')) {
|
$PAGE->requires->js($themedir . '/' . current_theme() . '/javascript/theme.js');
|
}
|
Result:
Coding error detected, it must be fixed by a programmer: Attempt to require a JavaScript file that does not exist.
|
Expected Result:
The file will be found (as proven by file_exists() returning true above) and included.
- has been marked as being related by
-
MDL-72461 PAGE->require->js handles moodle_urls differently
-
- Closed
-