function system_update_8004

Add a (id, default_langcode, langcode) composite index to entities.

File

core/modules/system/system.install, line 1665

Code

function system_update_8004() {
  // \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema was changed in
  // https://www.drupal.org/node/2261669 to include a (id, default_langcode,
  // langcode) compound index, but this update function wasn't added until
  // https://www.drupal.org/node/2542748. Regenerate the related schemas to
  // ensure they match the currently expected status.
  $manager = \Drupal::entityDefinitionUpdateManager();
  foreach (array_keys(\Drupal::entityTypeManager()->getDefinitions()) as $entity_type_id) {
    // Only update the entity type if it already exists. This condition is
    // needed in case new entity types are introduced after this update.
    if ($entity_type = $manager->getEntityType($entity_type_id)) {
      $manager->updateEntityType($entity_type);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.