MDL-69187 files: normalize retrieval of mimetypes from groups array.

Ensure that the following both return consistently, so that filepicker
form elements behave the same for each when defining "accepted_types":

    '.html, .txt'
    ['.html', '.txt']
This commit is contained in:
Paul Holden 2023-07-06 21:10:11 +01:00
parent e998f14061
commit e66f04e61d
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -2068,9 +2068,12 @@ function get_mimetype_description($obj, $capitalise=false) {
*/
function file_get_typegroup($element, $groups) {
static $cached = array();
// Turn groups into a list.
if (!is_array($groups)) {
$groups = array($groups);
$groups = preg_split('/[\s,;:"\']+/', $groups, -1, PREG_SPLIT_NO_EMPTY);
}
if (!array_key_exists($element, $cached)) {
$cached[$element] = array();
}