Problem/Motivation

Given that we do have a module with custom block type config
When we update the current Drupal 8 site to 8.3.x
And we enable the module which create new block types
And we go to "/admin/reports/status"
Then we will see the following:

Errors found

ENTITY/FIELD DEFINITIONS
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Custom block

The Translation source field needs to be installed.
The Translation outdated field needs to be installed.
The Translation author field needs to be installed.
The Translation status field needs to be installed.
The Translation created time field needs to be installed.

When we try create a custom block from that Block type
Then It will not work
And we get some of the following errors in the log:

[Tue May 16 12:02:35.044450 2017] [:error] [pid 21174] [client 127.0.0.1:59294] Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'content_translation_source' in 'field list': INSERT INTO {block_content_field_data} (id, revision_id, type, langcode, info, changed, revision_created, revision_user, revision_translation_affected, default_langcode, content_translation_source, content_translation_outdated, content_translation_uid, content_translation_status, content_translation_created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14); Array\n(\n    [:db_insert_placeholder_0] => 2\n    [:db_insert_placeholder_1] => 2\n    [:db_insert_placeholder_2] => test_block\n    [:db_insert_placeholder_3] => en\n    [:db_insert_placeholder_4] => Homepage carousel\n    [:db_insert_placeholder_5] => 1494925354\n    [:db_insert_placeholder_6] => 1494925354\n    [:db_insert_placeholder_7] => 1\n    [:db_insert_placeholder_8] => 1\n    [:db_insert_placeholder_9] => 1\n    [:db_insert_placeholder_10] => und\n    [:db_insert_placeholder_11] => 0\n    [:db_insert_placeholder_12] => 1\n    [:db_insert_placeholder_13] => 1\n    [:db_insert_placeholder_14] => 1494925303\n)\n" at /var/www/html/dev/drupal0803/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 777, referer: http://localhost/dev/drupal0803/docroot/block/add/test_block?destination=/dev/drupal0803/docroot/admin/structure/block/block-content


Proposed resolution

Manual fix:

drush entity-updates

The following updates are pending:

block_content entity type : 
  The Translation source field needs to be installed.
  The Translation outdated field needs to be installed.
  The Translation author field needs to be installed.
  The Translation status field needs to be installed.
  The Translation created time field needs to be installed.
Do you wish to run all pending updates? (y/n):

Automated fix: with every update in the late stages of updates.

  // Entity updates to clear up any mismatched entity and/or field definitions
  // And Fix changes were detected in the entity type and field definitions.
  \Drupal::entityDefinitionUpdateManager()->applyUpdates();

Remaining tasks

Automate the fix, if that is the right direction

Comments

RajabNatshah created an issue. See original summary.

Rajab Natshah’s picture

Status: Active » Needs review

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

Status: Needs review » Active

Setting to active, as there is no patch to review.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

szato’s picture

I've run into the same issue.

Adding code to the hook_update_N() fixed my probleme:

  $field_storage_definition = BaseFieldDefinition::create('language')
    ->setLabel(t('Translation source'))
    ->setDescription(t('The source language from which this translation was created.'))
    ->setDefaultValue(LanguageInterface::LANGCODE_NOT_SPECIFIED)
    ->setInitialValue(LanguageInterface::LANGCODE_NOT_SPECIFIED)
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE);

  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('content_translation_source', 'block_content', 'block_content', $field_storage_definition);

  $field_storage_definition = BaseFieldDefinition::create('boolean')
    ->setLabel(t('Translation outdated'))
    ->setDescription(t('A boolean indicating whether this translation needs to be updated.'))
    ->setDefaultValue(FALSE)
    ->setInitialValue(FALSE)
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE);

  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('content_translation_outdated', 'block_content', 'block_content', $field_storage_definition);

  $field_storage_definition = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Translation author'))
    ->setDescription(t('The author of this translation.'))
    ->setSetting('target_type', 'user')
    ->setSetting('handler', 'default')
    ->setRevisionable(TRUE)
    ->setDefaultValueCallback('ContentTranslationHandler::getDefaultOwnerId')
    ->setTranslatable(TRUE);

  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('content_translation_uid', 'block_content', 'block_content', $field_storage_definition);

  $field_storage_definition = BaseFieldDefinition::create('created')
    ->setLabel(t('Translation created time'))
    ->setDescription(t('The Unix timestamp when the translation was created.'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE);

  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('content_translation_created', 'block_content', 'block_content', $field_storage_definition);

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.