ConstraintManager::getDefinitionsByType does not validate definitions and can lead to a crash

Created on 31 March 2025, 2 days ago

Problem/Motivation

Spinning from πŸ› Validation constraint "type" must be an array of types Active

The definition has the key type which is intended to be an array, which isn't clear at all. If someone makes a mistake there is a WSOD due to passing a string to in_array

     if ($definition['type'] === FALSE || in_array($type, $definition['type'])) {
        $definitions[$plugin_id] = $definition;
      }

Steps to reproduce

See https://git.drupalcode.org/project/experience_builder/-/merge_requests/786

Proposed resolution

Cast type to an array, always. Or provide validation and error with an exception to clearly state what must be fixed.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

typed data system

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

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

Comments & Activities

Production build 0.71.5 2024