Problem/Motivation

Currently, the maximum file size limits are not respected in the right way. The ManagedFileTest illustrates this in a clear way: WebformElementManagedFile's maxFilesize is always at least 2 MB, even when setting it much lower (for example, 80 KB).

In this issue, it's also planned to handle the edge case when there's no max file size configured. Currently, the module returns null for the maxFilesize field. It should return the default PHP/Drupal max file size limit.

Proposed resolution

  • adapt $registry->addFieldResolver('WebformElementManagedFileBase', 'maxFilesize'', $callback) field resolver
  • Write a new test for the edge case when no file size limit is set

API changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hazn created an issue. See original summary.

hazn’s picture

patch from the mr

hazn’s picture

Status: Active » Needs review
pfrenssen’s picture

Status: Needs review » Needs work

Thanks for starting this and adding a test! I reviewed the code and left a comment on the MR. Let's follow the same logic as used in the Webform module.

pfrenssen’s picture

The Webform module also has a limit on the upload size across all files in a form. This is controlled with the form_file_limit limit in the webform, and the global setting settings.default_form_file_limit.

This is not in scope of this issue but it would be great if we can adhere to this as well. I created a feature request for this: #3482192: Respect the per-form file limit.

pfrenssen’s picture

Created a bug report in the Webform module about the PHP limit being ignored under certain circumstances: #3482402: Upload filesize limit doesn't properly account for PHP max upload setting.

  • pfrenssen committed 9d50cb04 on 2.x authored by hazn
    Issue #3478477 by hazn, pfrenssen: Fix querying for maxFileSize of...
pfrenssen’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.