Skip to content

Commit

Permalink
MDL-56673 templatelibrary: return false when core template doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Nov 1, 2016
1 parent f4f89d4 commit 8297422
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions admin/tool/templatelibrary/classes/api.php
Expand Up @@ -111,7 +111,7 @@ public static function list_templates($component = '', $search = '', $themename
*
* @param string $component The component that holds the template.
* @param string $template The name of the template.
* @return string the template
* @return string the template or false if template doesn't exist.
*/
public static function load_canonical_template($component, $template) {
// Get the list of possible template directories.
Expand All @@ -133,7 +133,8 @@ public static function load_canonical_template($component, $template) {
}

if ($filename === false) {
throw new moodle_exception('filenotfound', 'error');
// There are occasions where we don't have a core template.
return false;
}

$templatestr = file_get_contents($filename);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/templatelibrary/classes/external.php
Expand Up @@ -107,7 +107,7 @@ public static function load_canonical_template_parameters() {
*
* @param string $component The component that holds the template.
* @param string $template The name of the template.
* @return string the template
* @return string the template, false if template doesn't exist.
*/
public static function load_canonical_template($component, $template) {
$params = self::validate_parameters(self::load_canonical_template_parameters(),
Expand Down

0 comments on commit 8297422

Please sign in to comment.