From b3d7eb6ed4164033a5a225166fd1b2fb4daf31cd Mon Sep 17 00:00:00 2001 From: sam marshall Date: Thu, 22 Jan 2015 13:27:50 +0000 Subject: [PATCH] MDL-48946 Files: New custom description format_string call The format_string call used when getting file type descriptions does not specify a context. The page context is not always available at this point, so for consistency it should specify the system context. --- lib/filelib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/filelib.php b/lib/filelib.php index 6e52e0401d4..b893cf22f98 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1667,8 +1667,11 @@ function get_mimetype_description($obj, $capitalise=false) { $customdescription = mimeinfo('customdescription', $filename); if ($customdescription) { // Call format_string on the custom description so that multilang - // filter can be used (if enabled). - $result = format_string($customdescription); + // filter can be used (if enabled on system context). We use system + // context because it is possible that the page context might not have + // been defined yet. + $result = format_string($customdescription, true, + array('context' => context_system::instance())); } else if (get_string_manager()->string_exists($safemimetype, 'mimetypes')) { $result = get_string($safemimetype, 'mimetypes', (object)$a); } else if (get_string_manager()->string_exists($safemimetypestr, 'mimetypes')) {