diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 8214a5d..271c8a4 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -777,7 +777,10 @@ function _menu_translate(&$router_item, $map, $to_arg = FALSE) { $router_item['tab_parent_href'] = implode('/', $tab_parent_map); $router_item['options'] = array(); if (!empty($router_item['route_name'])) { + // Route-provided menu items do not have menu loaders, so replace the map + // with the link map. $map = $link_map; + $route_provider = Drupal::getContainer()->get('router.route_provider'); $route = $route_provider->getRouteByName($router_item['route_name']); $router_item['access'] = menu_item_route_access($route, $router_item['href'], $map); @@ -967,8 +970,7 @@ function menu_item_route_access(Route $route, $href, &$map) { // Attempt to match this path to provide a fully built request to the // access checker. try { - $attributes = Drupal::service('router.dynamic')->matchRequest($request); - $request->attributes->add($attributes); + $request->attributes->add(Drupal::service('router.dynamic')->matchRequest($request)); } catch (NotFoundHttpException $e) { return FALSE; @@ -978,9 +980,13 @@ function menu_item_route_access(Route $route, $href, &$map) { $path_bits = explode('/', trim($route->getPath(), '/')); foreach ($map as $index => $map_item) { $matches = array(); + // Search for placeholders wrapped by curly braces. For example, a path + // 'foo/{bar}/baz' would return 'bar'. if (isset($path_bits[$index]) && preg_match('/{(?.*)}/', $path_bits[$index], $matches)) { - if (isset($attributes[$matches['placeholder']])) { - $map[$index] = $attributes[$matches['placeholder']]; + // If that placeholder is present on the request attributes, replace the + // placeholder in the map with the value. + if ($request->attributes->has($matches['placeholder'])) { + $map[$index] = $request->attributes->get($matches['placeholder']); } } }