diff --git a/core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php b/core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php index 0b788b5..cdef380 100644 --- a/core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php +++ b/core/lib/Drupal/Core/Access/AccessArgumentsResolverFactory.php @@ -21,15 +21,20 @@ class AccessArgumentsResolverFactory implements AccessArgumentsResolverFactoryIn * {@inheritdoc} */ public function getArgumentsResolver(RouteMatchInterface $route_match, AccountInterface $account, Request $request = NULL) { - $upcasted_route_arguments = $route_match->getParameters()->all(); - $raw_route_arguments = $route_match->getRawParameters()->all(); + $route = $route_match->getRouteObject(); + + // Defaults for the parameters defined on the route object need to be added + // to the raw arguments. + $raw_route_arguments = $route_match->getRawParameters()->all() + $route->getDefaults(); - // @todo Remove this once AccessManagerInterface::checkNamedRoute() is fixed - // to not leak _raw_variables from the request being duplicated. - // @see https://drupal.org/node/2265939 - $raw_route_arguments += $upcasted_route_arguments; + $upcasted_route_arguments = $route_match->getParameters()->all(); - $wildcard_arguments = [$route_match->getRouteObject(), $route_match, $account]; + // Parameters which are not defined on the route object, but still are + // essential for access checking are passed as wildcards to the argument + // resolver. An access-check method with a parameter of type Route, + // RouteMatchInterface, AccountInterface or Request will receive those + // arguments regardless of the parameter name. + $wildcard_arguments = [$route, $route_match, $account]; if (isset($request)) { $wildcard_arguments[] = $request; } diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index 8eb564c..5b2f871 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -165,13 +165,11 @@ public function checkNamedRoute($route_name, array $parameters, AccountInterface try { $route = $this->routeProvider->getRouteByName($route_name, $parameters); - // Populate a new route match with both raw and converted parameters. - $parameters += $route->getDefaults(); - - // @todo: do we really need this? and why not ROUTE_NAME? + // ParamConverterManager relies on the route object being available + // from the parameters array. $parameters[RouteObjectInterface::ROUTE_OBJECT] = $route; - $upcasted_parameters = $this->paramConverterManager->convert($parameters, new Request()); + $route_match = new RouteMatch($route_name, $route, $upcasted_parameters, $parameters); return $this->check($route_match, $account); }