Change record status: 
Project: 
Introduced in branch: 
8.8.x
Introduced in version: 
8.8.0
Description: 

BaseFieldDefinition::isStorageRequired() used to fall back to ::isRequired() if the setter method ::setStorageRequired() has not been used to populate the storage required flag.

Unfortunately this causes various problems if one acts according to the documentation of BaseFieldDefinition::isStorageRequired() and adds NOT NULL constraints to the database schema of a storage required base field. In this case it will be not possible to override the base field for a bundle and make it non-required. It is also not possible to make the base field non-required. In both cases the reason is an added NOT NULL constraint to the database, which will not be removed by updating a field to be non-required.

Therefore BaseFieldDefinition::isStorageRequired() does not fall back to ::isRequired() anymore.

If you used that fallback and relied on BaseFieldDefinition::isStorageRequired() to return TRUE, because you have flagged the field as required only but not as storage required, then you will have to update the base fields for which you have that expectation and explicitly flag them as storage required.

An example for such update from core:

Field definition change:

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
     $fields['entity_type'] = BaseFieldDefinition::create('string')
       ->setLabel(t('Entity type'))
       ->setRequired(TRUE)
       ->setStorageRequired(TRUE)
       ->setDescription(t('The entity type to which this comment is attached.'))
       ->setSetting('is_ascii', TRUE)
       ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH);

Update:

function comment_update_8801() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_definition = $definition_update_manager->getFieldStorageDefinition('entity_type', 'comment');
  $field_definition->setStorageRequired(TRUE);
  $definition_update_manager->updateFieldStorageDefinition($field_definition);