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:
type: editor.editor.* has a image_upload.max_size key — used to indicate max image file size
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
- A new
type: bytes
- 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:
- 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.
- 👆 that required adding
\Drupal\Component\Utility\Bytes::validateConstraint()
Data model changes
None.
Release notes snippet
None.
Comments
Comment #2
wim leersThis blocks #3412361: Mark Editor config schema as fully validatable.
Change record: https://www.drupal.org/node/3416738.
Comment #4
wim leersComment #5
smustgrave commentedRemoved 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.
Comment #6
wim leersThanks! Did what you asked: #3008064-29: Deprecate vocabulary weight property.
Comment #9
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!
Comment #10
wim leersPublished CR: https://www.drupal.org/node/3416738
Rebased and unpostponed #3412361: Mark Editor config schema as fully validatable.