function system_update_8008

Purge field schema data for uninstalled entity types.

File

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

Code

function system_update_8008() {
  $entity_types = \Drupal::entityTypeManager()->getDefinitions();
  /** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $schema */
  $schema = \Drupal::keyValue('entity.storage_schema.sql');
  foreach ($schema->getAll() as $key => $item) {
    list($entity_type_id, , ) = explode('.', $key);
    if (!isset($entity_types[$entity_type_id])) {
      $schema->delete($key);
    }
  }
}

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