diff --git a/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php b/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php index 1825a1e..d71c50e 100644 --- a/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php +++ b/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php @@ -20,10 +20,12 @@ class Broken extends BlockBase { * {@inheritdoc} */ public function build() { - 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(); + $build = $this->brokenMessage(); + } + else { + $build = $this->brokenMessageGeneral(); } return $build; } @@ -49,4 +51,17 @@ protected function brokenMessage() { return $build; } + /** + * General message without debugging information for broken block. + * + * @return array + * Render array containing debug information. + */ + protected function brokenMessageGeneral() { + $build['message'] = [ + '#markup' => $this->t('Something goes wrong with $label section.', ['%label' => $this->label()]) + ]; + return $build; + } + }