Node changes (title change, publish/unpublish) don't get updated to the breadcrumb.

Example steps to reproduce:

  1. Install and configure varnish
  2. Install and configure purge, varnish_purger and suitable set of submodules
  3. Create a node unpublished
  4. Try to show the node without an access to view unpublished nodes
  5. Publish it
  6. Reload the page, notice a breadcrumb with "Access denied" instead of current page title

Running drush p-queue-work doesn't help as expected, but cache-rebuild does the trick (on an empty dev site, on another site it doesn't somehow affect either...). It's not a proper workaround anyway.

Also, the title stays there in the breadcrumb when unpublishing a node. If I add

if ($node = $route_match->getParameter('node')) {
  $breadcrumbs->addCacheTags(['node:' . $node->id() ]);
}

to BreadcrumbBuilder.php, the breadcrumb gets updated instantly on node unpublish, but this doesn't help on other cases.

Comments

jhuhta created an issue. See original summary.

greg boggs’s picture

Hi Jhuhta,

Can you look at the addCacheTags call from easy_breadcrumb and try that code in here? I'd do it, but replicating your set up is a few steps, and I've got a super busy week ahead.

jhuhta’s picture

StatusFileSize
new698 bytes

Sure I would, but there's no addCacheTags() call in easy_breadcrumb. Only these:

    $breadcrumb->addCacheContexts(['url.path']);
    $breadcrumb->addCacheableDependency($this->config);

First of which is already there in current_page_crumb, and the latter, well, the module has no config.

I have to correct myself. The three lines code in the summary fixes the breadcrumb updating on node title change. Hence the patch.

The "access denied" problem still persists and it's not varnish related: publishing an previously unpublished node still shows "access denied" in the breadcrumb until cache-rebuild.

khiminrm’s picture

Hi!

Patch from #3 works for me for updating breadcrumb after editing node's title.

Thanks!

greg boggs’s picture

So, if I'm following this thread correctly, this will fail for entities, users and taxonomy terms as well? And it will fail in both Breadcrumb modules for D8?

tea.time’s picture

Noting that I replicated this issue and that the patch in #3 fixed it for me, for node page breadcrumbs.

However, I imagine Greg is right in #5, that the problem would affect any entity whose label sets the page title... I have never fully understood where the entity view routes were provided, so I looked it up, and it seems this class does so - the `canonical` route:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
So I think one way to be truly dynamic would be to check if the current route matches an `entity.[entity_type_id].canonical` route, and then add that entity's cache tags...?

greg boggs’s picture

        // Expire the cache per url.
        $breadcrumb->addCacheContexts(['url.path']);

        // Expire cache context for config changes.
        $breadcrumb->addCacheableDependency($this->config);

        return $breadcrumb->setLinks($links);
      }
    }

    // Handle views path expiration cache expiration.
    $parameters = $route_match->getParameters();
    foreach ($parameters as $key => $parameter) {
      if ($key === 'view_id') {
        $breadcrumb->addCacheTags(['config:views.view.' . $parameter]);
      }

      if ($parameter instanceof CacheableDependencyInterface) {
        $breadcrumb->addCacheableDependency($parameter);
      }
    }

    // Expire cache by languages and config changes.
    $breadcrumb->addCacheContexts(['url.path', 'languages']);
    $breadcrumb->addCacheableDependency($this->config);
porchlight’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

Attaching a patch based off easy_breadcrumb implementation and comment #7.

  • Greg Boggs committed 5c87bf4 on 8.x-1.x authored by porchlight
    Issue #2871340 by jhuhta, porchlight, Greg Boggs: Cached breadcrumb not...
greg boggs’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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