Problem/Motivation

After deploying breadcrumbs will break depending on which language is visited first. E.g. if you visit about on spanish first after deploying then the spanish breadcrumb will be correct, but the english breadcrumb will be just `Home` This also happens in reverse if the english site is visited first after a deploy.

Clearing the cache in the ui fixes the breadcrumbs for both languages at least temporarily

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicxvan created an issue. See original summary.

nicxvan’s picture

@greg-boggs pointed me at a similar solution in easy breadcrumb. If this gets merged please include him in the credit.

Greg Boggs made their first commit to this issue’s fork.

nicxvan’s picture

Here is a patch file for deployments

sutharsan’s picture

Status: Active » Needs work

This duplicates adding the route and url.path context. However, without this breadcrumbs still disappear occassionally.

This comment gives me an uncomfortable feeling, it sounds like a hack to me. Do we understand why the bug occurs?

sutharsan’s picture

It would be beneficial to have at least the steps to reproduce the problem, i.e. which Drupal setup. Some suggestion: Interface translation y/n, content translation y/n, menu translatable y/n, menu-items translatable y/n, url alias differs per language y/n, active trail differs per language y/n

I don't experience the problem in my set-up (yet), but I do have collected the cache contexts of the breadcrumb block (used renderviz module):

  • "languages:language_content",
  • "languages:language_interface",
  • "route.menu_active_trails:main",
  • "url.path",
  • "user.permissions"
nicxvan’s picture

Thank you for responding, I am not sure what you mean about the change being unrelated.

It is a bit hard to reproduce but I will answer your questions.

We do have some interface translation but not for breadcrumbs.
Content, menu, menu items are all translated.

The url alias is the same on both languages, but we use the path '/es' to handle language negotiation.
The active trail is the same on both.

nicxvan’s picture

This may not be related to the languages. I found a core bug that has the exact same behavior:

https://www.drupal.org/project/drupal/issues/2875276

If I clear the cache while on the home page then no breadcrumbs ever show up.

renatog’s picture

@nicxvan do you know the steps to "how to reproduce" that?

I have a similar issue that that breadcrumb doesn't appear in some languages in production, but is working fine locally. I have a guess that is related to memcached. But I'm not really sure. I'm curious because seems to be similar

nicxvan’s picture

@renatoG I've never been able to fully pin down the cause. We don't use Memcache anymore so it's not likely related to that.

stefan.korn’s picture

I also experienced this issue, little different. All of a sudden menu breadcrumb stopped working. Finally found out that it was related to facet pretty paths and Search API. There was a node that had the same URL Alias as a search display. As soon as I renamed the node and cleared the cache, menu breadcrumb was working again.

It seemed that facet pretty paths somehow added its query parameters to all node requests and thus menu breadcrumb did not find itself responsible anymore (applies method) for any nodes. Strange enough that this kills all node breadcrumbs ...

phjou’s picture

I am also experiencing something similar, but in case I identified that the breadcrumb breaks everytime I visit a node.

Example:
-- Visit custom route, breadcrumb show
-- Visit node
-- Visit same custom route, breadcrumb disappears

And I need to flush the cache in order for the breadcrumb to reappear on the custom route.

EDIT: was the fault of a custom preprocess that was emptying the whole content including the cache tags.

xurizaemon’s picture

Version: 8.x-1.16 » 2.0.x-dev
Status: Needs work » Postponed (maintainer needs more info)

There is a Menu Breadcrumb fix related to route parameter matching in #3392139: Wrong breadcrumb due to route alterations which might be of interest. Thanks for linking #2875276: Breadcrumbs disappears when starting with front-page after cache rebuild (for anonymous user). as well Nic.

duaelfr’s picture

Assigned: Unassigned » duaelfr
Status: Postponed (maintainer needs more info) » Needs work

I faced this issue too but a bit different as it was not language related but user related.
I think I found steps to reproduce and the underlying cause of this.

Steps to reproduce

  1. Create three pages: /test1, /test2 and /test3 (paths are important)
  2. Add two pages to the main menu: [root] > test2 > test3 (test1 is not in the menu)
  3. Clear all caches
  4. Access /test1 - expected breadcrumb: [Home]
  5. Access /test2 - expected breadcrumb: [Home] > test2
  6. Access /test3 - expected breadcrumb: [Home] > test2 > test3

Current results:

  • Breadcrumb for /test1: [Home]
  • Breadcrumb for /test2: [Home]
  • Breadcrumb for /test3: [Home]

Note: [Home] only shows if breadcrumbs are configured that way. If they are not, the breadcrumb just disappear.

Why is that?

This seems to be related to the way Core caches its own breadcrumbs. The way Core builds its breadcrumbs only needs to know the parent path of the current page. That's why they declare url.path.parent as a cache context and not url.path like Menu Breadcrumb does. What happens is that if you first load a page where the breadcrumb is not managed by Menu Breadcrumb, then the breadcrumb block will be held in cache for every other pages sharing the same parent path. While using url.path.parent is a nice optimization in the Core's breadcrumbs management, it's what's causing our issue here.

duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Needs work » Needs review

As you can see in !22, the fix is quite simple and I believe it would also fix the original issue explained in the IS.

nicxvan’s picture

My god, all this time...
I'll add this to the site and test.

cyu’s picture

I was tasked with debugging some quirky breadcrumb issues this week, and I wasn't able to reliably replicate the problem until I came across the details in #15. With that info, I was able to get my local site into the state of having invalid breadcrumbs and can confirm that the fix in !22 has resolved my issues.

@duaelfr: Thanks for the patch and the detailed explanation. The timing of cache clears, our menu structure, and the order of pages visited meant that we hadn't been seeing this outside of production, but what you've described aligns with what I'm seeing (not related to language).

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

This looks great!

RTBC also hid the old MR that didn't work for me.

nicxvan changed the visibility of the branch 3230481-breadcrumbs-disappear-until to hidden.

nicxvan’s picture

Status: Reviewed & tested by the community » Needs work

On second thought you probably want to vary on language and route too.

If someone wants to make that change I can test and preserve my ability to RTBC

greg boggs’s picture

Adding a patch of the current MR for testing purposes

nicxvan’s picture

Status: Needs work » Reviewed & tested by the community

@greg-boggs let me know on slack he tested that context and it is not needed.

RTBC again

nicxvan’s picture

ben.hamelin’s picture

Good morning! Just chiming in here, this fixed an issue we were dealing with where the breadcrumb was being driven by the assignment to a Group. Alias was derived from the group path, but breadcrumb was being cached. Thanks everyone!

  • xurizaemon committed d0397b57 on 2.0.x authored by duaelfr
    Issue #3230481 by nicxvan, greg boggs, duaelfr, sutharsan, renatog,...
xurizaemon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all! And thanks @nicxvan for the nudge to land this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicxvan’s picture

greg boggs’s picture

Looks good.