From 90f517cf1f3fcd91aba5e94ea38e39a8dae03508 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Thu, 5 May 2022 18:33:20 +0800 Subject: [PATCH] MDL-74584 course: New optional parameter in get_module_types_names() Adds new parameter in get_module_types_names() to optionally reset the $modnames static cache. --- course/lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/course/lib.php b/course/lib.php index 46668cecd28..37c89ebc3e4 100644 --- a/course/lib.php +++ b/course/lib.php @@ -391,12 +391,13 @@ function course_integrity_check($courseid, $rawmods = null, $sections = null, $f * and the value is a lang_string object with a human-readable string. * * @param bool $plural If true, the function returns the plural forms of the names. + * @param bool $resetcache If true, the static cache will be reset * @return lang_string[] Localised human-readable names of all used modules. */ -function get_module_types_names($plural = false) { +function get_module_types_names($plural = false, $resetcache = false) { static $modnames = null; global $DB, $CFG; - if ($modnames === null) { + if ($modnames === null || $resetcache) { $modnames = array(0 => array(), 1 => array()); if ($allmods = $DB->get_records("modules")) { foreach ($allmods as $mod) {