Reproduce:
- Add a new file type with mime type image/*.
- Edit field instance settings to allow only the Image file type and excluding the newly created file type.
- Use media internet to add a file that fits the two file types mime rules.
- An error occurs "Only the following types of files are allowed to be uploaded: image, etc ..."
Problem:
media_file_validate_types() uses file_get_type() function form file_entity.file_api.inc which will returns the value of the first file type match, regardless if the type is allowed or not for the field.
function file_get_type($file) {
$types = module_invoke_all('file_type', $file);
drupal_alter('file_type', $types, $file);
return empty($types) ? NULL : reset($types);
}
Proposed solution
Replace file_get_type() in media_file_validate_types() by file_entity_get_filetype_candidates() to validate the file against all allowed file types for the field instance.
Related issues
Comments
Comment #2
mkhamash commentedComment #3
mkhamash commentedComment #4
mkhamash commentedComment #5
abu-zakham commentedI have re-rolled the patch in #2 to work with the latest development version.
Comment #6
joseph.olstadreviewing now
Comment #9
joseph.olstadfixed in 7.x-3.x dev and 7.x-2.x dev