diff -u b/core/modules/block/block.module b/core/modules/block/block.module --- b/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -5,7 +5,6 @@ * Controls the visual building blocks a page is constructed with. */ -use Drupal\block\BlockOperationsProviderInterface; use Drupal\Component\Utility\Html; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Installer\InstallerKernel; @@ -13,6 +12,7 @@ use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\language\ConfigurableLanguageInterface; +use Drupal\system\BlockOperationsProviderInterface; use Drupal\system\Entity\Menu; use Drupal\block\Entity\Block; @@ -328,7 +328,12 @@ } foreach ($operations as $operation) { - $operation['url']->setOption('query', ['destination' => 'admin/structure/block']); + if ($operation['url']->getOption('query')) { + $operation['url']->mergeOptions('query', ['destination' => 'admin/structure/block']); + } + else { + $operation['url']->setOption('query', ['destination' => 'admin/structure/block']); + } } return $operations; reverted: --- b/core/modules/block/src/BlockOperationsProviderInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -getEntity(); $links = []; - if (\Drupal::currentUser()->hasPermission('edit any' . $entity->bundle() . ' block content')) { + + // Check the current user has the appropriate permission to edit this + // custom block. + if ($this->account->hasPermission('edit any ' . $entity->bundle() . ' block content')) { // Set url options to an empty array. $links['block-edit'] = [ 'title' => $this->t('Edit block'), diff -u b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php --- b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php @@ -9,6 +9,7 @@ use Drupal\Core\Menu\MenuActiveTrailInterface; use Drupal\Core\Menu\MenuLinkTreeInterface; use Drupal\Core\Menu\MenuTreeParameters; +use Drupal\Core\Session\AccountInterface; use Drupal\system\BlockOperationsProviderInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; @@ -52,4 +53,11 @@ /** + * The current user. + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $user; + + /** * Constructs a new SystemMenuBlock. * @@ -65,12 +73,15 @@ * The active menu trail service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler used to check whether menu_ui is installed. + * @param \Drupal\Core\Session\AccountInterface $user + * The current user. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail, ModuleHandlerInterface $module_handler) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MenuLinkTreeInterface $menu_tree, MenuActiveTrailInterface $menu_active_trail, ModuleHandlerInterface $module_handler, AccountInterface $user) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->menuTree = $menu_tree; $this->menuActiveTrail = $menu_active_trail; $this->moduleHandler = $module_handler; + $this->user = $user; } /** @@ -83,7 +94,8 @@ $plugin_definition, $container->get('menu.link_tree'), $container->get('menu.active_trail'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('current_user'), ); } @@ -253,7 +265,8 @@ $menu = $this->getDerivativeId(); $links = []; - if ($this->moduleHandler->moduleExists('menu_ui') && \Drupal::currentUser()->hasPermission('administer menu')) { + // Check the current user has the appropriate permission to edit menus. + if ($this->moduleHandler->moduleExists('menu_ui') && $this->user->hasPermission('administer menu')) { $links['menu-edit'] = [ 'title' => $this->t('Edit menu'), 'url' => Url::fromRoute('entity.menu.edit_form', ['menu' => $menu]), diff -u b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php --- b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php @@ -253,7 +253,8 @@ $delta = $this->getDerivativeId(); [$view, $display_id] = explode('-', $delta, 2); $links = []; - if ($this->moduleHandler->moduleExists('views_ui') && \Drupal::currentUser()->hasPermission('administer views')) { + // Check the current user has the appropriate permission to edit views. + if ($this->moduleHandler->moduleExists('views_ui') && $this->user->hasPermission('administer views')) { $links['view-edit'] = [ 'title' => $this->t('Edit view'), 'url' => Url::fromRoute('entity.view.edit_display_form', [