From 6a4ba9df64b0591b686575dc613c00a875437504 Mon Sep 17 00:00:00 2001 From: catch Date: Fri, 28 Mar 2014 14:51:56 +0100 Subject: [PATCH] Issue #2124599 by olli, tedbow, swentel: ode_block_access affects access to editing blocks Removes 'operations' links for Block layout page. --- .../lib/Drupal/node/Tests/NodeBlockFunctionalTest.php | 5 +++++ core/modules/node/node.module | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index c68789c9aa6..148ec233a64 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -153,6 +153,11 @@ class NodeBlockFunctionalTest extends NodeTestBase { $this->assertText($label, 'Block was displayed on the node/N when node is of type article.'); $this->drupalGet('node/' . $node5->id()); $this->assertNoText($label, 'Block was not displayed on nodes of type page.'); + + $this->drupalLogin($this->adminUser); + $this->drupalGet('admin/structure/block'); + $this->assertText($label, 'Block was displayed on the admin/structure/block page.'); + $this->assertLinkByHref(url('admin/structure/block/manage/' . $block->id())); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d84778868b9..7c429aeacdb 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -8,7 +8,6 @@ * API pattern. */ -use Drupal\Component\Utility\String; use Drupal\Core\Language\Language; use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Cache\Cache; @@ -23,6 +22,8 @@ use Drupal\Core\Template\Attribute; use Drupal\file\Entity\File; use Drupal\language\Entity\Language as LanguageEntity; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Drupal\block\Entity\Block; +use Drupal\Core\Session\AccountInterface; /** * Denotes that the node is not published. @@ -1075,7 +1076,11 @@ function node_form_block_form_alter(&$form, &$form_state) { * Checks the content type specific visibility settings and removes the block * if the visibility conditions are not met. */ -function node_block_access($block) { +function node_block_access(Block $block, $operation, AccountInterface $account, $langcode) { + // Only affect access when viewing the block. + if ($operation != 'view') { + return; + } $visibility = $block->get('visibility'); if (!empty($visibility)) { if (!empty($visibility['node_type']['types'])) {