diff --git a/core/modules/block_content/src/BlockContentAccessControlHandler.php b/core/modules/block_content/src/BlockContentAccessControlHandler.php index d0c19c5..e3b555e 100644 --- a/core/modules/block_content/src/BlockContentAccessControlHandler.php +++ b/core/modules/block_content/src/BlockContentAccessControlHandler.php @@ -19,7 +19,7 @@ class BlockContentAccessControlHandler extends EntityAccessControlHandler { */ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { - return AccessResult::allowed(); + return AccessResult::allowedIf($entity->isPublished()); } return parent::checkAccess($entity, $operation, $account); } diff --git a/core/modules/block_content/src/BlockContentStorageSchema.php b/core/modules/block_content/src/BlockContentStorageSchema.php index 18b5443..5a54100 100644 --- a/core/modules/block_content/src/BlockContentStorageSchema.php +++ b/core/modules/block_content/src/BlockContentStorageSchema.php @@ -17,25 +17,11 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping); if ($storage_definition->getName() == 'status') { + // Set all block content as published. $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; - } } diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 4f3ad57..2afd040 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -147,8 +147,8 @@ public function blockSubmit($form, FormStateInterface $form_state) { * {@inheritdoc} */ protected function blockAccess(AccountInterface $account) { - if ($block = $this->getEntity()) { - return AccessResult::allowedIf($block->isPublished() && $block->access('view', $account, TRUE)); + if ($this->getEntity()) { + return $this->getEntity()->access('view', $account, TRUE); } return AccessResult::forbidden(); }