Skip to content

Commit

Permalink
MDL-74584 course: New optional parameter in get_module_types_names()
Browse files Browse the repository at this point in the history
Adds new parameter in get_module_types_names() to optionally reset
the $modnames static cache.
  • Loading branch information
Mihail Geshoski committed May 6, 2022
1 parent c23b67b commit 90f517c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions course/lib.php
Expand Up @@ -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) {
Expand Down

0 comments on commit 90f517c

Please sign in to comment.