Problem/Motivation

There are a number of places in Drupal core and contrib have configuration that specifies a certain amount of bytes: from memory limits to maximum file sizes, to minimum file sizes, to upload limits, and so on.

In Drupal core there are at least two use cases:

  1. type: editor.editor.* has a image_upload.max_size key — used to indicate max image file size
  2. type: base_file_field_field_settings has a max_file_size key — used to indicate the max file size for file fields

There's lots of contrib use cases for this too — I spotted one in Webform for example.

Steps to reproduce

N/A

Proposed resolution

  1. A new type: bytes
  2. A new CallbackValidator callback: \Drupal\Component\Utility\Bytes::validateConstraint()

Remaining tasks

Review.

User interface changes

None.

API changes

Two API additions:
No changes, but 2 API additions:

  1. A new type: bytes config schema type, see CR: https://www.drupal.org/node/3416738. (We'll be able to use that for base_file_field_field_settings.max_filesize too. There's lots of contrib use cases for this too — I spotted one in Webform for example.
  2. 👆 that required adding \Drupal\Component\Utility\Bytes::validateConstraint()

Data model changes

None.

Release notes snippet

None.

Issue fork drupal-3422407

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

Wim Leers created an issue. See original summary.

wim leers’s picture

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Removed the MR appears to have test coverage.

CR reads well, the before/after is a great touch for those like myself who are visual with the examples.

Since this is a blocker for other things going to go ahead and mark it now.

wim leers’s picture

  • catch committed 81abe57f on 10.3.x
    Issue #3422407 by Wim Leers, smustgrave: New config schema data type:...

  • catch committed 757ca2c5 on 11.x
    Issue #3422407 by Wim Leers, smustgrave: New config schema data type:...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

wim leers’s picture

Status: Fixed » Closed (fixed)

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