diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index 5e935e0..5959fd0 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -227,7 +227,7 @@ public function checkNamedRoute($route_name, array $parameters = array(), Reques public function check(Route $route, Request $request) { $checks = $route->getOption('_access_checks') ?: array(); - $conjunction = $route->getOption('_access_mode') ?: 'ANY'; + $conjunction = $route->getOption('_access_mode') ?: 'ALL'; if ($conjunction == 'ALL') { return $this->checkAll($checks, $route, $request); diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index 5b87e2f..5827975 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -2,8 +2,6 @@ block.admin_demo: path: '/admin/structure/block/demo/{theme}' defaults: _content: '\Drupal\block\Controller\BlockController::demo' - options: - _access_mode: 'ALL' requirements: _access_theme: 'TRUE' _permission: 'administer blocks' diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php index f60e51a..1931191 100644 --- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php +++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php @@ -48,9 +48,6 @@ public function routes(RouteBuildEvent $event) { array( '_access_theme' => 'TRUE', '_permission' => 'administer blocks', - ), - array( - '_access_mode' => 'ALL', ) ); $collection->add("block.admin_display_$key", $route); diff --git a/core/modules/book/book.routing.yml b/core/modules/book/book.routing.yml index 39aff5c..4d28c2d 100644 --- a/core/modules/book/book.routing.yml +++ b/core/modules/book/book.routing.yml @@ -23,8 +23,6 @@ book.export: path: '/book/export/{type}/{node}' defaults: _controller: '\Drupal\book\Controller\BookController::bookExport' - options: - _access_mode: 'ALL' requirements: _permission: 'access printer-friendly version' _entity_access: 'node.view' @@ -33,8 +31,6 @@ book.outline: path: '/node/{node}/outline' defaults: _entity_form: 'node.book_outline' - options: - _access_mode: 'ALL' requirements: _permission: 'administer book outlines' _entity_access: 'node.view' @@ -44,8 +40,6 @@ book.admin_edit: defaults: _form: 'Drupal\book\Form\BookAdminEditForm' _title: 'Re-order book pages and change titles' - options: - _access_mode: 'ALL' requirements: _permission: 'administer book outlines' _entity_access: 'node.view' diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php index 03e5d75..561f110 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Routing/ContentTranslationRouteSubscriber.php @@ -62,6 +62,7 @@ public function routes(RouteBuildEvent $event) { '_permission' => 'translate any entity', ), array( + '_access_mode' => 'ANY', 'parameters' => array( 'entity' => array( 'type' => 'entity:' . $entity_type, @@ -85,6 +86,7 @@ public function routes(RouteBuildEvent $event) { '_access_content_translation_manage' => 'create', ), array( + '_access_mode' => 'ANY', 'parameters' => array( 'entity' => array( 'type' => 'entity:' . $entity_type, @@ -106,6 +108,7 @@ public function routes(RouteBuildEvent $event) { '_access_content_translation_manage' => 'update', ), array( + '_access_mode' => 'ANY', 'parameters' => array( 'entity' => array( 'type' => 'entity:' . $entity_type, diff --git a/core/modules/edit/edit.routing.yml b/core/modules/edit/edit.routing.yml index 27bced7..41acaac 100644 --- a/core/modules/edit/edit.routing.yml +++ b/core/modules/edit/edit.routing.yml @@ -16,8 +16,6 @@ edit.field_form: path: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}' defaults: _controller: '\Drupal\edit\EditController::fieldForm' - options: - _access_mode: 'ALL' requirements: _permission: 'access in-place editing' _access_edit_entity_field: 'TRUE' @@ -26,8 +24,6 @@ edit.entity_save: path: '/edit/entity/{entity_type}/{entity}' defaults: _controller: '\Drupal\edit\EditController::entitySave' - options: - _access_mode: 'ALL' requirements: _permission: 'access in-place editing' _access_edit_entity: 'TRUE' diff --git a/core/modules/editor/editor.routing.yml b/core/modules/editor/editor.routing.yml index 46b4fba..3308dd0 100644 --- a/core/modules/editor/editor.routing.yml +++ b/core/modules/editor/editor.routing.yml @@ -2,8 +2,6 @@ editor.field_untransformed_text: path: '/editor/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}' defaults: _controller: '\Drupal\editor\EditorController::getUntransformedText' - options: - _access_mode: 'ALL' requirements: _permission: 'access in-place editing' _access_edit_entity_field: 'TRUE' diff --git a/core/modules/filter/filter.routing.yml b/core/modules/filter/filter.routing.yml index 93bb987..92f5672 100644 --- a/core/modules/filter/filter.routing.yml +++ b/core/modules/filter/filter.routing.yml @@ -38,8 +38,6 @@ filter.admin_disable: path: '/admin/config/content/formats/manage/{filter_format}/disable' defaults: _entity_form: 'filter_format.disable' - options: - _access_mode: 'ALL' requirements: _filter_disable_format_access: 'TRUE' _permission: 'administer filters' diff --git a/core/modules/node/node.routing.yml b/core/modules/node/node.routing.yml index c2a4ff1..4108f1a 100644 --- a/core/modules/node/node.routing.yml +++ b/core/modules/node/node.routing.yml @@ -17,6 +17,8 @@ node.add_page: defaults: _title: 'Add page' _content: '\Drupal\node\Controller\NodeController::addPage' + options: + _access_mode: 'ANY' requirements: _permission: 'administer content types' _node_add_access: 'node' diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php index 413cd8d..9100f45 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php @@ -92,6 +92,8 @@ public function routes() { // The HTTP method is a requirement for this route. '_method' => $method, '_permission' => "restful $lower_method $this->pluginId", + ), array( + '_access_mode' => 'ANY', )); switch ($method) { diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php index 02bfd03..5564ba4 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php +++ b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php @@ -64,10 +64,7 @@ public function routes(RouteBuildEvent $event) { '_search_plugin_view_access' => $plugin_id, '_permission' => 'search content', ); - $options = array( - '_access_mode' => 'ALL', - ); - $route = new Route($path, $defaults, $requirements, $options); + $route = new Route($path, $defaults, $requirements); $collection->add('search.view_' . $plugin_id, $route); } } diff --git a/core/modules/search/search.routing.yml b/core/modules/search/search.routing.yml index b71c85b..6780e69 100644 --- a/core/modules/search/search.routing.yml +++ b/core/modules/search/search.routing.yml @@ -19,8 +19,6 @@ search.view: _content: '\Drupal\search\Controller\SearchController::searchView' plugin_id: NULL keys: '' - options: - _access_mode: 'ALL' requirements: keys: '.+' _permission: 'search content' diff --git a/core/modules/system/tests/modules/router_test/router_test.routing.yml b/core/modules/system/tests/modules/router_test/router_test.routing.yml index 0aab01a..3217c98 100644 --- a/core/modules/system/tests/modules/router_test/router_test.routing.yml +++ b/core/modules/system/tests/modules/router_test/router_test.routing.yml @@ -48,6 +48,8 @@ router_test.8: router_test.9: path: '/router_test/test9' + options: + _access_mode: 'ANY' defaults: _controller: '\Drupal\router_test\TestControllers::test8' requirements: diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php index 097cdd3..d12f5c0 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php @@ -183,6 +183,13 @@ public function providerTestCheckConjunctions() { 'expected' => FALSE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_4', + 'condition_one' => AccessCheckInterface::ALLOW, + 'condition_two' => AccessCheckInterface::KILL, + 'expected' => FALSE, + ); + $access_configurations[] = array( 'conjunction' => 'ALL', 'name' => 'test_route_5', 'condition_one' => AccessCheckInterface::ALLOW, @@ -190,6 +197,13 @@ public function providerTestCheckConjunctions() { 'expected' => FALSE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_5', + 'condition_one' => AccessCheckInterface::ALLOW, + 'condition_two' => AccessCheckInterface::DENY, + 'expected' => FALSE, + ); + $access_configurations[] = array( 'conjunction' => 'ALL', 'name' => 'test_route_6', 'condition_one' => AccessCheckInterface::KILL, @@ -197,6 +211,13 @@ public function providerTestCheckConjunctions() { 'expected' => FALSE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_6', + 'condition_one' => AccessCheckInterface::KILL, + 'condition_two' => AccessCheckInterface::DENY, + 'expected' => FALSE, + ); + $access_configurations[] = array( 'conjunction' => 'ALL', 'name' => 'test_route_7', 'condition_one' => AccessCheckInterface::ALLOW, @@ -204,6 +225,13 @@ public function providerTestCheckConjunctions() { 'expected' => TRUE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_7', + 'condition_one' => AccessCheckInterface::ALLOW, + 'condition_two' => AccessCheckInterface::ALLOW, + 'expected' => TRUE, + ); + $access_configurations[] = array( 'conjunction' => 'ALL', 'name' => 'test_route_8', 'condition_one' => AccessCheckInterface::KILL, @@ -211,6 +239,13 @@ public function providerTestCheckConjunctions() { 'expected' => FALSE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_8', + 'condition_one' => AccessCheckInterface::KILL, + 'condition_two' => AccessCheckInterface::KILL, + 'expected' => FALSE, + ); + $access_configurations[] = array( 'conjunction' => 'ALL', 'name' => 'test_route_9', 'condition_one' => AccessCheckInterface::DENY, @@ -218,6 +253,13 @@ public function providerTestCheckConjunctions() { 'expected' => FALSE, ); $access_configurations[] = array( + 'conjunction' => NULL, + 'name' => 'test_route_9', + 'condition_one' => AccessCheckInterface::DENY, + 'condition_two' => AccessCheckInterface::DENY, + 'expected' => FALSE, + ); + $access_configurations[] = array( 'conjunction' => 'ANY', 'name' => 'test_route_10', 'condition_one' => AccessCheckInterface::ALLOW, @@ -282,7 +324,7 @@ public function testCheckConjunctions($conjunction, $name, $condition_one, $cond '_access' => static::convertAccessCheckInterfaceToString($condition_one), '_test_access' => static::convertAccessCheckInterfaceToString($condition_two), ); - $options = array('_access_mode' => $conjunction); + $options = $conjunction ? array('_access_mode' => $conjunction) : array(); $route = new Route($name, array(), $requirements, $options); $route_collection->add($name, $route);