Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By plopesc on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
Following the rename of config entity type for "field storage definitions" ("$field" in Drupal 7) to 'field_storage_config':
- hook_field_update_forbid() has been renamed to hook_field_storage_config_update_forbid().
- Drupal\field\FieldUpdateForbiddenException has been renamed to Drupal\field\FieldStorageConfigUpdateForbiddenException.
7.x
function mymodule_field_update_forbid($field, $prior_field, $has_data) {
if ($has_data) {
throw new FieldUpdateForbiddenException("Cannot update a list field not to include keys with existing data");
}
}
8.x
use Drupal\field\FieldStorageConfigInterface;
use Drupal\field\FieldStorageConfigUpdateForbiddenException;
function mymodule_field_storage_config_update_forbid(FieldStorageConfigInterface $field, FieldStorageConfigInterface $prior_field) {
if ($field->hasData()) {
throw new FieldStorageConfigUpdateForbiddenException("Cannot update a list field not to include keys with existing data");
}
}
Impacts:
Module developers