Hello
I've developed module
Forbidden File Format →
The logic of this module based on disabling of upload validator 'file_validate_extensions' and adding my own validator.
It's possible if I'll do this:
$item['#upload_validators']['file_validate_extensions'] = array();
then Drupal will allow to upload any types of files.
But I have a problem in function template_preprocess_file_upload_help()
There is this code
if (isset($upload_validators['file_validate_extensions'])) {
$descriptions[] = t('Allowed types: @extensions.', array('@extensions' => $upload_validators['file_validate_extensions'][0]));
}
In my case the $upload_validators['file_validate_extensions'] is empty array and IF returns TRUE, but index 0 in $upload_validators['file_validate_extensions'][0] isn't set and I get notice.
In the multiple mode of field function "template_preprocess_file_upload_help" execute from this code
$elements['#file_upload_description'] = array(
'#theme' => 'file_upload_help',
'#description' => '',
'#upload_validators' => $elements[0]['#upload_validators'],
'#cardinality' => $cardinality,
);
and there is no way to avoid this notice. If I'll unset $upload_validators['file_validate_extensions'] then Drupal will allow default extensions of file. But I should allow all extensions in Drupal and deny some extensions in my module.
I think that more logical is check that index 0 also has been set.