- Issue created by @KlemenDEV
When uploading an image that is larger than constraints and the image is resized, the file size reported in FileValidationEvent does not match the actual file size.
The issue was originally reported in https://www.drupal.org/project/drupal/issues/3292350 🐛 file_validate_image_resolution does not update file size after resizing Needs work , but was fixed for hook_file_validate, but I think this issue appeared again with this event.
ClamAV contrib module switched from hook_file_validate to FileValidationEvent and it appears that in some cases, the file scanning logic now breaks.
If we log file size (uploading test PNG file that will be resized) as reported by the FileInterface in both FileValidationEvent and hook_file_validate, it seems they return different data.
$file_size = filesize($file->getFileUri());
\Drupal::logger('File validate')->error('Size of file is: ' . $file->getSize() . ', URI is: ' . $file->getFileUri() . ' file size is: ' . $file_size);
Using hook_file_validate, this logs
Size of file is: 387365, URI is: /tmp/phpzipzoE file size is: 387365
but using FileValidationEvent logs
Size of file is: 387365, URI is: /tmp/phpuX8xcs file size is: 506707
Active
11.1 🔥
image system