Changes to the menu title of a node do not appear until after the cache is flushed.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 2908966-17.patch | 1.26 KB | wim leers |
| #7 | easy_breadcrumb_cache_clear_2908966_7.patch | 742 bytes | useernamee |
Changes to the menu title of a node do not appear until after the cache is flushed.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 2908966-17.patch | 1.26 KB | wim leers |
| #7 | easy_breadcrumb_cache_clear_2908966_7.patch | 742 bytes | useernamee |
Comments
Comment #2
greg boggsI am going to reuse this issue for the feature request for clearing the cache based on menu edits if and only if the menu is used for config.
Here's a link to the capitalize port issue https://www.drupal.org/project/easy_breadcrumb/issues/2917195.
Comment #3
greg boggsComment #4
greg boggsComment #5
greg boggsComment #6
useernamee commentedHey,
I have looked a bit into this issue and for me this is not generally true. When I change the title also the breadcrumb changes if the url path has changed. If url path doesn't change (if you change a character or word in title that gets excluded from the path then breadcrumb stays the same).
One possibility would be to check whether current path is from some kind of entity and add a cacheTag.
Comment #7
useernamee commentedThis patch adds a cacheTag to breadcrumbs of nodes and taxonomy terms.
Comment #8
renatog commentedComment #9
greg boggsWould you mind adding a code comment for this one?
Comment #10
useernamee commentedWith route parameters it is very easy to check entity type. And if the type is node or taxonomy term I add Cache Tags to the breadcrumb object that invalidates cache when this particular entity is updated.
Is this what you meant or did you mean that I put a comment into code?
Comment #11
greg boggsI understand now. Should we add User? Will this then not work on content entities such as a Comment or Groups page?
~G
Comment #12
useernamee commenteddrupal debug:entitygives you list of entities (which can be then added as cacheTags to breadcumb object) and their types. So for comments we should also add comment (and user for user - that would work if user changes username). For group page I am not sure since I am not familiar with this module.Comment #13
greg boggsYea, what if someone updates the title of a view that's being used in the crumb without changing the url... same problem yes?
There's gotta be a way to easily expire whenever the current page changes.
Comment #14
useernamee commentedYeah views are another issue here. But the problem is a bit more persistent. If you change for example the view title in view settings and you don't change the page link where this view is shown then, whenever you visit this page you will see the old view title in crumb (until the cache is cleared). I investigated the issue and I did not find a way how to solve this problem globally. We can find some solutions for users, comments and views (and so on) but the obstacle I can not overcome is how to check whether the internal path corresponds to existing entity type and what are its cache tags then.
Comment #15
greg boggsI see! Thank you! I'll follow up with some folks who know for some advice and see what we can do to fix this. Ideally, I need this to work for any generated custom entity type. My employer, ThinkShout, uses a lot of custom entities. Can't have breadcrumbs breaking for my team!
There used to be a setting in Drupal 7 that did this for blocks... I'm sure there's a way.
~G
Comment #16
greg boggshttps://twitter.com/wimleers/status/984823835479429120
Comment #17
wim leers#7 kinda fixes it, and does work, but it's of course not a generic solution. Manually constructing cache tags is something you should avoid whenever possible.
The "proper" way would be
Entity::getCacheTags(). If you could, then you could do something that's even better:We can get the parameters by calling
$route_match->getParameters(). And we can then check if they'reinstanceof EntityInterface. Better yet … we can do this generically, not just for entities, but for any route parameter that is a cacheable dependency, entity or otherwise!Here's a patch to get you started :) It already implements a superset of the patch in #7.
Comment #18
useernamee commentedThis still doesn't work for views. At first I though it doesn't work for config entities but it works for webforms by adding
"config:webform.webform.<webform_id>", "config:webform.settings", "webform:<webform_id>"cache tags. It also works for taxonomy_vocabularies and node_types (I checked those 4).For views we would need to add
"config:views.view.<view_id>. You can get this cache tag if you load a view manually and callgetCacheTags()method, but you don't get view entity through$route_match->getParameters(). You only get'view_id'through which we could manually create cache tags. I wonder why is it, that it doesn't work for views? We also need to find out for which other content types this method doesn't work.Comment #19
greg boggsMind adding custom logic to correct the views cache tag? We should follow up with a core issue like I did for delete form page titles, but it helps if we have a work around I can point the core developer to in Easy Breadcrumb.
Comment #20
useernamee commentedLike this?
Comment #21
wim leersFor e.g. the
/taxonomy/term/{taxonomy_term}view, you mean?You could do
View::load($view_id).Views is special, because a view for e.g. the
/taxonomy/term/{taxonomy_term}path does not result in aviewroute parameter being loaded, hence it's not detected automatically.Comment #22
useernamee commentedWell I looked into cache tags of vocabulary ( structure > taxonomy > List terms ), because I wondered whether breadcrumb will get cache tags - and it gets them. So If I change the label of vocabulary and the machine name stays the same the breadcrumb changes to the new label.
Do you think it is better to load view to get its cache tags rather than manual tag creation like I proposed?
Comment #23
wim leersIt's using the API, which means that it'll also work on sites with modules that alter Views' config entities. It is more expensive, so if profiling shows this is critical for performance, then go with your proposed approach specifically for Views!
Comment #25
greg boggsI went with the lazy way to add a view cache tag. ;)
Comment #26
useernamee commentedWell I am leaning more towards Wim's solution with loading a View and then
addCacheableDependency, but I have no idea how much heavier this solution is.Comment #27
wim leersIt is much heavier. This is a sensible compromise for now. OTOH: …