Problem/Motivation

Ran into this while working on #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support.

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

Issue fork drupal-3404039

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

Assigned: wim leers » Unassigned
Status: Active » Needs review
Issue tags: +blocker, +Needs Review Queue Initiative
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Was pretty easy to review. The test-only feature was already ran and shows the issue.

Using the early return fixed it.

LGTM!

borisson_’s picture

I agree with @smustgrave, this was pretty easy to review. RTBC++

alexpott’s picture

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

Committed and pushed 156533febb to 11.x and 664f6ffad1 to 10.2.x. Thanks!

  • alexpott committed 156533fe on 11.x
    Issue #3404039 by Wim Leers: PluginExistsConstraintValidator should...

  • alexpott committed 664f6ffa on 10.2.x
    Issue #3404039 by Wim Leers: PluginExistsConstraintValidator should...

Status: Fixed » Closed (fixed)

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