In #2542748: Automatic entity updates can fail when there is existing content, leaving the site's schema in an unpredictable state, core stopped supporting automated/auto-magical updating of entity field definitions post entity install. The CR for this change states:

...that magic was removed and now changes to the entity schema are to be included as regular update functions.

Good stuff. As a result, the Entity Definition Update Manager provides a number of helper functions for updating these definitions "correctly."

Custom module maintainers may, however, attempt updates that will result in either a no-op or a mismatched field definition vs. an installed schema. Consider the example of a string field; a developer may believe it possible to update the schema thusly:

$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
/** @var \Drupal\Core\Field\BaseFieldDefinition $field_storage_definition */
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('field_name', 'entity_name');
$field_storage_definition->setSetting('max_length', 51);
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);

This will update the definition, partly, however the schema of the backing field will not be changed and the entity will continue to show as needing an update in the Status Report UI. Since the UI message does not provide context beyond "needs update," this can result in frustration and confusion.

Since the entity definition update manager is a developer-facing API with no UI attached, it would be appropriate to throw some type of runtime exception when we can detect such changes won't "take."

Comments

bradjones1 created an issue. See original summary.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Totally agree such issues have to be raised at the development level, so that the risk of having them in the status report after deployment is mitigated. Site owners reading the status report will be confused, and this is surely a developer job to understand and solve as early as possible!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.