-
Bug
-
Resolution: Fixed
-
Minor
-
2.9.4, 3.1.13, 3.2.9, 3.3.7, 3.4.4, 3.5.1, 3.6
-
MOODLE_29_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-52966_static_cache_core_filetypes_get_types -
Static caching in core_filetypes::get_types does not fully work because the cache is set at the end:
self::$cachedtypes = $mimetypes;
|
return self::$cachedtypes;
|
but if there are no custom types, the fragment above is never reached because of:
// If there are no custom types, just return.
|
$custom = self::get_custom_types();
|
if (empty($custom)) {
|
return $mimetypes;
|
}
|
Very simple fix is:
// If there are no custom types, just return.
|
$custom = self::get_custom_types();
|
if (empty($custom)) {
|
self::$cachedtypes = $mimetypes;
|
return self::$cachedtypes;
|
}
|
Profiling run with a course with a lot of resources, before the fix:
get_mimetypes_array 7,617 0.3% 1,520,192 12.9% 20,065
and after the fix:
get_mimetypes_array 7,617 0.3% 24,501 0.3% 16,603