Filesize not provided in PlUploadFile::validatePlUploadFile

Created on 10 June 2022, over 2 years ago
Updated 24 April 2023, almost 2 years ago

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.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇳🇿New Zealand ericgsmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024