Problem/Motivation
In `\Drupal\plupload\Element\PlUploadFile::validatePlUploadFile` a file entity is created and passed through to `file_validate` without the filesize populated. This can cause issue for anything that is calling getSize inside hook_file_validate.
Steps to reproduce
This code can be used to validate the filesize is missing.
function example_file_validate(Drupal\file\FileInterface $file) {
if (!$file->getSize()) {
$errors[] = t('The file is empty (%filesize).', ['%filesize' => format_size($file->getSize())]);
}
}
Proposed resolution
Add filesize when creating the file entity.
Comments
Comment #2
ericgsmith commentedPatch attached
Comment #4
budalokko commentedFiles created by core "managed_file" FAPI element do have it, so yes, files created by our module should have it too.
Committed, thanks !!