diff -u b/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install --- b/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -202,7 +202,25 @@ function taxonomy_update_8702() { - $database = \Drupal::database(); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); - $database->update('taxonomy_term__parent') - ->fields(['langcode' => $default_langcode]) - ->execute(); + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + /** @var \Drupal\Core\Field\BaseFieldDefinition $field_storage_definition */ + $field_storage_definition = $definition_update_manager->getFieldStorageDefinition('parent', 'taxonomy_term'); + + // Only perform the update if the field is not translatable. It's possible + // that custom or contrib code has overridden this. + if (!$field_storage_definition->isTranslatable()) { + $default_langcode = \Drupal::languageManager() + ->getDefaultLanguage() + ->getId(); + // taxonomy_update_8502() populated the langcode field of + // 'taxonomy_term__parent' using the term's langcode but the field is not + // translatable. If taxonomy_post_update_make_taxonomy_term_revisionable() + // has already run prior to + // https://www.drupal.org/project/drupal/issues/3066439 then this will have + // already fixed the field. However on sites that have not run that update + // yet we need to run this update the langcode as calling + // \Drupal\Core\Entity\Sql\SqlContentEntityStorage::restore() no longer + // calls \Drupal\taxonomy\Entity\Term::preSave(). + \Drupal::database()->update('taxonomy_term__parent') + ->fields(['langcode' => $default_langcode]) + ->execute(); + } }