- Issue created by @jrglasgow
- πΊπΈUnited States jrglasgow Idaho
here is a patch that is working on my local system
- @jrglasgow opened merge request.
- Status changed to Needs review
almost 2 years ago 8:25pm 27 February 2023 - πΊπΈUnited States jwjoshuawalker San Diego
I'm confused on the wording. It looks like this patch is adding field validation to ensure that it obeys max upload size settings, is that correct?
While reading, I initially interpreted this as "let's just ignore max upload settings"; and I don't want to take that control away from site administrators.
- πΊπΈUnited States jrglasgow Idaho
in FileItem::getUploadValidators()
// Cap the upload size according to the PHP limit. $max_filesize = Bytes::toNumber(Environment::getUploadMaxSize()); if (!empty($settings['max_filesize'])) { $max_filesize = min($max_filesize, Bytes::toNumber($settings['max_filesize'])); } // There is always a file size limit due to the PHP server limit. $validators['file_validate_size'] = [ $max_filesize, ];
you see that the file_validate_size validator is set to the minimum of the Widget max_filesize and the PHP Max Upload size.
In the FileWidget::formElement() the description is set using those upload validators.
$file_upload_help = [ '#theme' => 'file_upload_help', '#description' => $element['#description'], '#upload_validators' => $element['#upload_validators'], '#cardinality' => $cardinality, ]; $element['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help);
The File size listed in this description is pulled out of the validators in template_preprocess_file_upload_help()
if (isset($upload_validators['file_validate_size'])) { $descriptions[] = t('@size limit.', [ '@size' => format_size($upload_validators['file_validate_size'][0]), ]); }
The actual validation for the file size using the Widget settings works fine as the comparison doesn't bother to look at the PHP Max Upload setting, as after it is uploaded it is too late to worry about that, but the description is already set.
This patch updates the validator file_validate_size with the correct size based on the field setting and recreates the description since the PHP Max Upload size limitation doesn't matter when using Uppy to upload files.
-
jwjoshuawalker β
committed 3c027c00 on 8.x-2.x authored by
jrglasgow β
Issue #3344775: Update element description file size limit
-
jwjoshuawalker β
committed 3c027c00 on 8.x-2.x authored by
jrglasgow β
- Status changed to Fixed
over 1 year ago 1:20am 24 March 2023 - πΊπΈUnited States jwjoshuawalker San Diego
I understand, thank you for the explanation.
Automatically closed - issue fixed for 2 weeks with no activity.