diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install index 2f9e49e..3817e0c 100644 --- a/core/modules/block_content/block_content.install +++ b/core/modules/block_content/block_content.install @@ -67,6 +67,12 @@ function block_content_update_8003() { * Add and populate publishing status fields. */ function block_content_update_8004() { + $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('block_content'); + $entity_keys = $entity_type->getKeys(); + $entity_keys['published'] = 'status'; + $entity_type->set('entity_keys', $entity_keys); + \Drupal::entityDefinitionUpdateManager()->updateEntityType($entity_type); + $status = BaseFieldDefinition::create('boolean') ->setLabel(new TranslatableMarkup('Publishing status')) ->setDescription(new TranslatableMarkup('A boolean indicating the published state.')) diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 42dbd53..b82a787 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -147,9 +147,8 @@ public function blockSubmit($form, FormStateInterface $form_state) { * {@inheritdoc} */ protected function blockAccess(AccountInterface $account) { - $block = $this->getEntity(); - if ($block->isPublished()) { - return $this->getEntity()->access('view', $account, TRUE); + if ($block = $this->getEntity()) { + return $block->isPublished() && $block->access('view', $account, TRUE); } return AccessResult::forbidden(); }