PluginExistsConstraintValidator should return early if given NULL

Created on 24 November 2023, 10 months ago
Updated 28 November 2023, 9 months ago

Problem/Motivation

Ran into this while working on πŸ“Œ Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed .

When the validator validates NULL, it triggers a deprecation error, followed by a nonsensical error message:

"The '' plugin does not exist.

Steps to reproduce

$block = Block::load('block.block.olivero_content');
$block->set('plugin', NULL);
$typed_data = $this->container->get('typed_data_manager');
$definition = $typed_data->createDataDefinition('entity:block');
$violations = $typed_data->create($definition, $block)->validate();

results in:

  1x: Deprecated NULL placeholder value for key (@plugin_id) in: "The '@plugin_id' plugin does not exist.". This will throw a PHP error in drupal:11.0.0. See https://www.drupal.org/node/3318826

Proposed resolution

Return early if $value === NULL, just like all other validation constraints: because there is no value to validate.

Remaining tasks

  1. Test coverage.
  2. Fix.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024