hook_field_purge_field() parameter definition is wrong.

Created on 5 December 2023, 7 months ago
Updated 19 December 2023, 6 months ago

Problem/Motivation

The hook_field_purge_field() parameter declaration is currently wrong and has been for a while, it's documented to expect a \Drupal\field\Entity\FieldConfig $field, however the calling field_purge_field function invokes it with a \Drupal\Core\Field\FieldDefinitionInterface instance instead.

Which causes a fatal error when a module developer implements that hook expecting it to work solely with a \Drupal\field\Entity\FieldConfig, but a field purge is called on a field definition that isn't a FieldConfig instance.

Steps to reproduce

Attempt a field purge on a normal FieldDefinition instance, but with a module implementing the hook_field_purge_field() hook as declared in field.api.php. A fatal error will occur.

TypeError: mymodule_field_purge_field(): Argument #1 ($field) must be of type Drupal\field\Entity\FieldConfig, Drupal\Core\Field\BaseFieldDefinition given in mymodule_field_purge_field()

Proposed resolution

Update parameter type to reflect the real world usage.

Remaining tasks

Provide issue fork/patch.

User interface changes

N/A.

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Postponed: needs info

Version

11.0 ๐Ÿ”ฅ

Component
Fieldย  โ†’

Last updated about 7 hours ago

Created by

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024