File Entity Always Gets File Size on Save

Created on 4 March 2016, over 8 years ago
Updated 11 February 2023, over 1 year ago

Problem/Motivation

File entities always get file size on save, even when the filesize attribute is manually set.

public function preSave(EntityStorageInterface $storage) {
  parent::preSave($storage);

  $this->setSize(filesize($this->getFileUri()));
}

This forces Drupal to look up the file size upon migration (from Drupal 7), rather than using what is provided.

Proposed resolution

Check if the filesize attribute is already set before running the filesize method

Remaining tasks

Needs adding a check fort the filesize attribute on the preSave method
Code review

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs work

Version

9.5

Component
File systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States wesleylima

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