Add config validation for weights (blocks, filters, etc. all use weights)

Created on 7 March 2024, 8 months ago
Updated 21 March 2024, 8 months ago

Problem/Motivation

Searching for weight: in all of Drupal core finds 21 matches.

All 21 look like this:

    weight:
      type: integer
      label: 'Weight'

πŸ‘† That means an arbitrary integer is allowed. We should add validation.

(See πŸ“Œ Add config validation for the allowed characters of machine names Fixed for a similar issue. Note: this blocks πŸ“Œ Make Block config entities fully validatable Fixed and many other issues.)

Steps to reproduce

N/A

Proposed resolution

I think that at a minimum, this should be restricted to the largest supported 32-bit integers. Per https://www.php.net/manual/en/reserved.constants.php, that's -2147483648 (PHP_INT_MIN on 32-bit systems) and 2147483647 (PHP_INT_MAX on 32-bit systems).

Note this also matches the supported (signed) integer value ranges in MySQL and MariaDB. Which makes sense, because those use 32 bits of storage.

IOW: "32-bits ought to be enough for expressing weights in Drupal".

Remaining tasks

None.

User interface changes

None.

API changes

API addition: weight config schema data type

Data model changes

None.

Release notes snippet

None.

πŸ“Œ Task
Status

Fixed

Version

10.3 ✨

Component
ConfigurationΒ  β†’

Last updated 1 day ago

Created by

πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024