diff --git a/core/modules/action/src/Tests/BulkFormTest.php b/core/modules/action/src/Tests/BulkFormTest.php index f04b9ce..0ceba4c 100644 --- a/core/modules/action/src/Tests/BulkFormTest.php +++ b/core/modules/action/src/Tests/BulkFormTest.php @@ -63,10 +63,6 @@ public function testBulkForm() { $edit["node_bulk_form[$i]"] = TRUE; } - // As a anonymous user you should not have actions available. - $result = $this->cssSelect('#edit-action option'); - $this->assertEqual(0, count($result)); - // Login as a user with 'administer nodes' permission to have access // to the bulk operation. $admin_user = $this->drupalCreateUser(['administer nodes']); diff --git a/core/modules/node/src/NodeAccessControlHandler.php b/core/modules/node/src/NodeAccessControlHandler.php index 818a791..3992cfd 100644 --- a/core/modules/node/src/NodeAccessControlHandler.php +++ b/core/modules/node/src/NodeAccessControlHandler.php @@ -70,6 +70,10 @@ public function access(EntityInterface $entity, $operation, $langcode = Language $result = AccessResult::forbidden()->cachePerRole(); return $return_as_object ? $result : $result->isAllowed(); } + if (in_array($operation, ['update', 'delete']) && $account->hasPermission('administer nodes')) { + $result = AccessResult::allowed()->cachePerRole(); + return $return_as_object ? $result : $result->isAllowed(); + } $result = parent::access($entity, $operation, $langcode, $account, TRUE)->cachePerRole(); return $return_as_object ? $result : $result->isAllowed(); } diff --git a/core/modules/node/src/Tests/Views/BulkFormTest.php b/core/modules/node/src/Tests/Views/BulkFormTest.php index 7da2042..449161b 100644 --- a/core/modules/node/src/Tests/Views/BulkFormTest.php +++ b/core/modules/node/src/Tests/Views/BulkFormTest.php @@ -29,7 +29,7 @@ class BulkFormTest extends NodeTestBase { */ public function testBulkForm() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); - $this->drupalLogin($this->drupalCreateUser(array('administer nodes'))); + $this->drupalLogin($this->drupalCreateUser(array('administer nodes', 'access content overview'))); $node = $this->drupalCreateNode(array( 'promote' => FALSE, )); diff --git a/core/modules/system/src/Entity/Action.php b/core/modules/system/src/Entity/Action.php index 4174dd9..ca3d8cf 100644 --- a/core/modules/system/src/Entity/Action.php +++ b/core/modules/system/src/Entity/Action.php @@ -21,9 +21,6 @@ * id = "action", * label = @Translation("Action"), * admin_permission = "administer actions", - * handlers = { - * "access" = "Drupal\system\Entity\ActionAccessControlHandler", - * }, * entity_keys = { * "id" = "id", * "label" = "label" diff --git a/core/modules/system/src/Entity/ActionAccessControlHandler.php b/core/modules/system/src/Entity/ActionAccessControlHandler.php deleted file mode 100644 index 8d336f8..0000000 --- a/core/modules/system/src/Entity/ActionAccessControlHandler.php +++ /dev/null @@ -1,27 +0,0 @@ -getPlugin()->access($operation, $account, TRUE); - } - -} diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index 57055d6..d5432ab 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -260,6 +260,7 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { $selected = array_filter($form_state->getValue($this->options['id'])); $entities = array(); $action = $this->actions[$form_state->getValue('action')]; + $count = 0; foreach (array_intersect_key($this->view->result, $selected) as $row) { $entity = $this->getEntity($row); @@ -268,6 +269,8 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { continue; } + $count++; + $entities[$entity->id()] = $entity; } @@ -278,7 +281,6 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { $form_state->setRedirect($operation_definition['confirm_form_route_name']); } - $count = count(array_filter($form_state->getValue($this->options['id']))); if ($count) { drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', array( '%action' => $action->label(), diff --git a/core/modules/user/src/Tests/Views/BulkFormTest.php b/core/modules/user/src/Tests/Views/BulkFormTest.php index 22af101..b1c95d7 100644 --- a/core/modules/user/src/Tests/Views/BulkFormTest.php +++ b/core/modules/user/src/Tests/Views/BulkFormTest.php @@ -38,11 +38,6 @@ public function testBulkForm() { // Login as a user without 'administer users. $this->drupalLogin($this->drupalCreateUser(array('administer permissions'))); - // Ensure that there are no actions available. - $this->drupalGet('test-user-bulk-form'); - $result = $this->cssSelect('#edit-action option'); - $this->assertEqual(0, count($result)); - // Create an user which actually can change users. $this->drupalLogin($this->drupalCreateUser(array('administer users'))); $this->drupalGet('test-user-bulk-form');