diff --git a/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php b/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php index 0e4732e49..1825a1e0b 100644 --- a/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php +++ b/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php @@ -20,7 +20,12 @@ class Broken extends BlockBase { * {@inheritdoc} */ public function build() { - return $this->brokenMessage(); + trigger_error($this->t('The block %label is broken or missing. You may be missing content or you might need to enable the original module.', ['%label' => $this->label()]), E_USER_ERROR); + $build['#cache']['contexts'] = ['user.roles']; + if (\Drupal::currentUser()->hasPermission('administer blocks')) { + $build += $this->brokenMessage(); + } + return $build; } /** @@ -38,7 +43,7 @@ public function blockForm($form, FormStateInterface $form_state) { */ protected function brokenMessage() { $build['message'] = [ - '#markup' => $this->t('This block is broken or missing. You may be missing content or you might need to enable the original module.') + '#markup' => $this->t('This block is broken or missing. You may be missing content or you might need to enable the original module.'), ]; return $build;