diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install index 3817e0c..f3441ec 100644 --- a/core/modules/block_content/block_content.install +++ b/core/modules/block_content/block_content.install @@ -71,6 +71,7 @@ function block_content_update_8004() { $entity_keys = $entity_type->getKeys(); $entity_keys['published'] = 'status'; $entity_type->set('entity_keys', $entity_keys); + $entity_type->setHandlerClass('storage_schema', 'Drupal\block_content\BlockContentStorageSchema'); \Drupal::entityDefinitionUpdateManager()->updateEntityType($entity_type); $status = BaseFieldDefinition::create('boolean') @@ -83,6 +84,4 @@ function block_content_update_8004() { \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('status', 'block_content', 'block_content', $status); - \Drupal::database()->update('block_content_field_data')->fields(['status' => 1])->execute(); - \Drupal::database()->update('block_content_field_revision')->fields(['status' => 1])->execute(); } diff --git a/core/modules/block_content/src/BlockContentStorageSchema.php b/core/modules/block_content/src/BlockContentStorageSchema.php index e69de29..4d10586 100644 --- a/core/modules/block_content/src/BlockContentStorageSchema.php +++ b/core/modules/block_content/src/BlockContentStorageSchema.php @@ -0,0 +1,41 @@ +getName() == 'status') { + $schema['fields']['status']['initial'] = 1; + } + + return $schema; + } + + /** + * {@inheritdoc} + */ + protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) { + $schema = parent::getEntitySchema($entity_type, $reset); + + $schema['block_content_field_data']['indexes'] += [ + 'block_content__status' => ['status'] + ]; + $schema['block_content_field_revision']['indexes'] += [ + 'block_content__status' => ['status'] + ]; + + return $schema; + } +} \ No newline at end of file diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 3ebbd79..5207c4f 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -20,6 +20,7 @@ * bundle_label = @Translation("Custom block type"), * handlers = { * "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage", + * "storage_schema" = "Drupal\block_content\BlockContentStorageSchema", * "access" = "Drupal\block_content\BlockContentAccessControlHandler", * "list_builder" = "Drupal\block_content\BlockContentListBuilder", * "view_builder" = "Drupal\block_content\BlockContentViewBuilder",