diff -u b/core/modules/system/src/PathBasedBreadcrumbBuilder.php b/core/modules/system/src/PathBasedBreadcrumbBuilder.php --- b/core/modules/system/src/PathBasedBreadcrumbBuilder.php +++ b/core/modules/system/src/PathBasedBreadcrumbBuilder.php @@ -144,7 +144,7 @@ $exclude['user'] = TRUE; // Because this breadcrumb builder is entirely path-based, vary by the 'url' // cache context. - $breadcrumb->setCacheContexts(['url']); + $breadcrumb->setCacheContexts(['url.path']); while (count($path_elements) > 1) { array_pop($path_elements); // Copy the path elements for up-casting. only in patch2: unchanged: --- a/core/core.services.yml +++ b/core/core.services.yml @@ -39,6 +39,11 @@ services: arguments: ['@request_stack'] tags: - { name: cache.context } + cache_context.url.path: + class: Drupal\Core\Cache\PathCacheContext + arguments: ['@request_stack'] + tags: + - { name: cache.context } cache_context.url.query_args: class: Drupal\Core\Cache\QueryArgsCacheContext arguments: ['@request_stack'] only in patch2: unchanged: --- /dev/null +++ b/core/lib/Drupal/Core/Cache/PathCacheContext.php @@ -0,0 +1,35 @@ +requestStack->getCurrentRequest(); + return $request->getBasePath() . $request->getPathInfo(); + } + +} only in patch2: unchanged: --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -533,12 +533,8 @@ function hook_contextual_links_plugins_alter(array &$contextual_links) { /** * Perform alterations to the breadcrumb built by the BreadcrumbManager. * - * @param array $breadcrumb - * An array of breadcrumb link a tags, returned by the breadcrumb manager - * build method, for example - * @code - * array('Home'); - * @endcode + * @param \Drupal\Core\Breadcrumb\Breadcrumb $breadcrumb + * A breadcrumb object returned by the breadcrumb manager build method. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The current route match. * @param array $context @@ -549,9 +545,9 @@ function hook_contextual_links_plugins_alter(array &$contextual_links) { * * @ingroup menu */ -function hook_system_breadcrumb_alter(array &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) { +function hook_system_breadcrumb_alter(Drupal\Core\Breadcrumb\Breadcrumb &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) { // Add an item to the end of the breadcrumb. - $breadcrumb[] = Drupal::l(t('Text'), 'example_route_name'); + $breadcrumb->addLink(Drupal::l(t('Text'), 'example_route_name')); } /** only in patch2: unchanged: --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -486,14 +486,14 @@ function menu_ui_preprocess_block(&$variables) { /** * Implements hook_system_breadcrumb_alter(). */ -function menu_ui_system_breadcrumb_alter(array &$breadcrumb, RouteMatchInterface $route_match, array $context) { +function menu_ui_system_breadcrumb_alter(&$breadcrumb, RouteMatchInterface $route_match, array $context) { // Custom breadcrumb behavior for editing menu links, we append a link to // the menu in which the link is found. if (($route_match->getRouteName() == 'menu_ui.link_edit') && $menu_link = $route_match->getParameter('menu_link_plugin')) { if (($menu_link instanceof MenuLinkInterface)) { // Add a link to the menu admin screen. $menu = Menu::load($menu_link->getMenuName()); - $breadcrumb[] = Link::createFromRoute($menu->label(), 'entity.menu.edit_form', array('menu' => $menu->id())); + $breadcrumb->addLink(Link::createFromRoute($menu->label(), 'entity.menu.edit_form', array('menu' => $menu->id()))); } } }