Stop passing null as the label to createEntityReferenceField

Created on 14 October 2025, 8 days ago

Problem/Motivation

The $field_label param for \Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait::createEntityReferenceField expects a string, but many times jsonapi (and once in views) we pass null. With strict types this is not allowed.

This also results in invalid schema:

field.field.*.*.* type is field_config_base
The label property type for field_config_base is required_label
The required_label has the NotBlank constraint.

Steps to reproduce

Add checkFunctionArgumentTypes: true to phpstan parameters
Run phpstan and grep for this function:

./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw | grep createEntityReferenceField

Proposed resolution

Pass a string based on the field name instead

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

jsonapi.module

Created by

🇦🇺Australia mstrelan

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