Problem/Motivation
Cache of entities are not invalidated when the entity label changes.
Steps to reproduce for nodes & breadcrumbs (from #3):
- Create a node with title 'Title A'.
- Change the title to 'Title B' and check the 'Create new revision'.
- Open the Revisions tab > Breadcrumb shows the right title (Title B).
- Change the title to 'Title C' and check the 'Create new revision'.
- Open the Revisions tab.
Expected: The title in the breadcrumb is 'Title C'.
Actual: the title in the breadcrumb is 'Title B'.
Steps to reproduce for users (from #48):
- Log in
- Edit your username and save.
- Return to the edit screen for your user account.
Expected: Breadcrumb shows your new username
Actual: You'll see your old username is still utilised in the breadcrumb.
Proposed resolution
Allow attaching cacheability metadata to titles with a new CacheableTitleResolverInterface that returns a static or dynamic title (with cacheable metadata).
Comments
Comment #2
matsbla commentedI noticed that the breadcrumb actually change until you enable content translation + add a new language + enable content type translation.
I did this:
- Created a node with title "Test Diff module 1"
- Made a new revision and changes title to "Test Diff module 2"
- Enabled content translation + added a new language + enabled content type translation
- Made a new revision and changes title to "Test Diff module 3"
The breadcrumb title will now always stay as "Test Diff module 2"
(Check attached new image)
In fact it seems like the revision tab is not displayed until:
- Content translation module is enable
- At least 2 languages are enabled
- The content type translation is enabled
I'm not sure if this is related?
Comment #3
juampynr commentedI could reproduce this in Drupal core by following these steps:
1. Create a node with title 'Title A'.
2. Change the title to 'Title B' and check the 'Create new revision'.
3. Open the Revisions tab > Breadcrumb shows the right title (Title B).
4. Change the title to 'Title C' and check the 'Create new revision'.
5. Open the Revisions tab.
Expected: the title in the breadcrumb is 'Title C'.
Actual: the title in the breadcrumb is 'Title B'.
Here is a screenshot where the breadcrumb shows 'Title I' while the page title shows 'Title J':
Comment #4
juampynr commentedComment #5
dawehnerMaybe we should add the cacheability metadata of each upcasted object, given that the output might differ depending on it.
Comment #6
juampynr commented@dawehner suggested in IRC to set the cache tag somewhere at PathBasedBreadcrumbBuilder.
Comment #8
juampynr commentedHere is a patch containing a test that demonstrates the steps that I listed at comment #3.
Comment #10
juampynr commentedThis patch fixes it when I test it manually but I must be doing something horribly wrong because the test that I wrote never ends.
Comment #11
berdirYes, we had a similar bug with local task access when the user had this permission.
While this might make sense, you should use addCacheableDependency($node). I'm also not sure if this is conceptually the right fix or if it's just fixing the problem as a side effect.
Comment #12
juampynr commentedThanks @berdir. Here is a new patch with your suggestion.
Comment #13
Trupti Bhosale commentedVerified the patch 'breadcrumb_shows_the-2607920-12.patch' in comment #12.Below are the observations
1.Reproduced the issue in drupal 8.2.x site
2.Applied the patch 'breadcrumb_shows_the-2607920-12.patch'
3.Cleared cache
4.Create a node with title 'Test 1.
5. Change the title to 'Test 2' and check the 'Create new revision'.
6. Open the Revisions tab > Breadcrumb shows the right title (Test 2).
7. Change the title to 'Test 3' and check the 'Create new revision'.
8. Open the Revisions tab, the breadcrumb now displayed right title (Test 3)
Attached snapshot for reference.
Comment #14
Trupti Bhosale commentedComment #15
catchCould still go into 8.0.x, didn't fully review yet.
Comment #16
catchThis could use a positive assertion - i.e. looking for 'Article Baz' as well as the negative one. If we had a bug where breadcrumbs didn't show on cache hits it'd pass too at the moment.
Tagging novice since that should be a one-line addition to the test.
Comment #17
sidharthapUpdated patch as per #16.
Comment #18
dawehnerI was wondering whether actually this should be added to EVERY EntityAccessControlHandler case instead.
Comment #19
berdirYes, I think we should do exactly that.
Comment #20
dawehner.
Comment #21
vg3095 commentedAdded CacheableDependency on every EntityAccessControlHandler case
Comment #23
vg3095 commentedComment #24
dawehnerThis doesn't address #18 yet at all, sorry.
Comment #25
vg3095 commentedSince I am new at this , can you please elaborate , what needs to be done.
Comment #26
himanshugautam commented@dawehner Is comment #18 talking about adding
+ $result->addCacheableDependency($entity);to all the EntityAccessControlHandler files?Comment #27
aludescher commentedThis is a proposed fix by adding the
addCacheableDependency()call to the parentaccess()method.The
access()method is only overridden by theNodeAccessControlHandlerclass. But thecheckAccess()method is implemented by most / all of them andaddCacheableDependency()is not called for everyAccessResultreturn object. What determines the use ofaddCacheableDependency()and why is it not called every time the $entity object exists?Comment #29
catch#2513570: Changing name (label) of content type is not reflected in breadcrumb link text is older than this, but less active.
Also has tests which could be copied here.
Comment #30
stpaultim commentedRemoving "novice" tag. It looks like the "novice" task mentioned in comment #16 was dealt with and the issue has gotten more complicated again.
Comment #35
kfritscheRe-rolling 27.
Applying patch from #2513570: Changing name (label) of content type is not reflected in breadcrumb link text as mentioned in #29.
Tested manually and it works now.
Reviewing the patch also looks good to me.
Lets see what Testbot thinks about it.
Comment #36
jonathanshawThe problem seems to be more generic than the original issue report? Issue needs retitling.
Comment #38
tstoecklerWas about to RTBC but the test failures made me think about this a bit harder. And now I'm convinced the fix is actually incorrect.
The bug that is being fixed here is that if the path-based breadcrumb comes across an entity view page, and so the entity's label ends up being part of the breadcrumb, that breadcrumb is not invalidated when the entity, and in particular the entity label, changes.
What the current patch does is to declare that when checking access for an entity the result of that access-checking always depends on the entity itself. This fixes the bug because part of the breadcrumb building involves access checking for the respective routes, which in turn checks access on the respective entities when encountering any entity view pages.
Fundamentally the assumption the patch makes, however, is wrong. The access result does not necessarily depend on the entity itself. In fact the most common case is that it solely depends on a permission. An example of an access result that does depend on the entity is the status field of nodes. But when checking that in
::checkAccess()NodeAccessControlHandleralready adds the entity as cacheability metadata as it should. In the particular case of this bug, the access result actually does not change (!), it's TRUE/allowed both before and after saving the node. So when looking at the access checking in isolation it is actually incorrect to invalidate the cache. In other words the patch introduces completely unwarranted invalidation and it just happens to be the case that that unwarranted invalidation solves the bug where the actual cached content (not the access) of the breadcrumb becomes stale.So now turning to the breadcrumb bug itself and ignoring the access checking what happens is that when fetching the entity label for the breadcrumb, that entity is not attached as cacheability metadata to that breadcrumb. That is the actual bug and what should be fixed here.
Taking a deeper look at that that is going to be a "fun" problem to solve. The entity label is the result of
TitleResolver::getTitle()which does all sorts of magic (from a predictability/cacheability point of view) involving the global request object, so not really sure how we are going to be able to do this. We need some way for (in this specific case)EntityController::title()to provide cacheability metadata about what it is doing and for that do end all the up the stack inPathBasedBreadcrumbBuilder::build(). That will require some creative thinking, I think, at least I'm coming up blank right now.Comment #39
tstoecklerOops, did not mean to change status.
Comment #40
tstoecklerSo here's something that seems to work: Since the argument resolver looks into
$request->attributesfor any arguments, simply putting acacheable_metadatakey there will allow title callbacks to have such an argument where they can pass along the data. This passes at least the tests added here (although there was one broken assertion in the test, see the respective interdiff).Notes:
$cacheable_metadataargument by reference, which is a bit unfortunateComment #42
kfritscheThanks for the feedback and fixing it. Sounds good for me.
Some minor remarks and the fix for these attached. This should fix most of the failing tests.
isset check needed
isset check needed
This could be done as a one liner with addCacheableDependency. This method takes care of all of these merges.
Comment #44
kfritscheFixing the mock in the PathBasedBreadcrumbBuilderTest, tests should pass now.
Open then these two todos. Any ideas?
Comment #45
tstoecklerNot really. I was too afraid to look into
EntityRepository::getTranslationContext()this morning. Did so now.So there's already this in there:
So if we simply move the
::addCacheableDependency()call after the::getTranslationFromContext()call we should be fine.Then there's also this:
That ends up invoking
hook_language_fallback_candidates(_OPERATION|)_alter(). So those hook implementations would need some way to pass cacheable metadata back up the stack, as well. The good thing is that these hooks already get a$contextparameter, so I guess we can just add theCacheableMetadataobject there.Interestingly, because Content Translation actually implements that hook, we should be able to reproduce a bug with the missing cache metadata there as well. Let's say there are two languages A and B and A has a higher weight than B and an entity with translations in both languages. If the translation in A is unpublished then any breadcrumb including the view page of that entity should show the title in language B. Then if the translation A is published, the cache will not be invalidated, so the breadcrumb will incorrectly still show the title in language B until the next cache clear. So we should be able to add a test that does exactly that, when fixing this.
All that said, maybe we can make the whole language fallback thing a separate follow-up issue, since this already fixes a legitimate bug.
Comment #46
kerby70 commentedAppears to me this may be caused, at least in part, by #2699627: url.path cache context for breadcrumbs is unnecessarily granular & #2719721: BreadcrumbBuilder::applies() mismatch with cacheability metadata; possibly related to #2685637: Edited feed item breadcrumb does not reflect the change.
Comment #47
dawehnerI'm wondering whether we should have a CacheableString or similar class which encapsulates the result of a computation together with its cacheable metadata, much like we do in other places.
Comment #48
chrisolofThis issue is present in 8.6.x and is not isolated to nodes. I just verified it happens with user entities as well. To reproduce just log in, edit your username, and save. Then return to the edit screen for your user account. You'll see your old username is still utilized in the breadcrumb.
Comment #49
tstoecklerOpened #3005360: Determining language fallback candidates does not account for cacheable metadata for #45.
The patch itself needed a rebase for the
ControllerResolver→ArgumentsResolverchange inTitleResolver.I then fixed the
getTranslationFromContext()thing mentioned in #45 and also added a@todoreferencing the aforementioned issue.Then I added a
CacheableTitleclass per #47.So this issue needs review again. In addition to the issue summary update I guess we also need a change record here to advertise the new method and also a follow-up to convert all remaining title callbacks in core to attach cacheability metadata. Possibly we also want to deprecate
TitleResolver::getTitle()(but - if so - certainly in a follow-up).Comment #51
tstoecklerFixed coding standards violations and
PathBasedBreadcrumBuilderTest.Comment #52
honyik commentedCan somebody please change the patch to work for 8.7.x? I still have this issue (for CT Articles)
Comment #53
jonathanshawComment #54
maks.khotynetskyi commentedHere is the patch for 8.7.x
Comment #56
OlgaRabodzei commentedHi!
Thanks to @makskhotynetskyi, patch above works good.
Comment #58
hugovk commentedConfirmed patch #52 works with latest Drupal 8.7.5.
Comment #60
badrange commentedThis is also an issue with 8.8.x. Attaching a patch, hoping that the tests will pass.
It looks to me like the tests for the 8.7.x patch fails because of a change in how the testbot handles calling of deprecated code. I wonder if it is even possible to make the tests pass for 8.7 as it is.
Comment #61
badrange commentedComment #63
badrange commentedFix test fails. The change in
core/modules/node/src/Controller/NodeViewController.phpneed a special notice - tests failed due to a deprecation notice that I removed here. I could not find a separate issue for this, please let me know if I should make one.Comment #64
badrange commentedComment #65
chris matthews commentedTested the patch in #63 and it works for me with the latest Drupal 8.7.6. Leaving the status as 'Needs review' for now in case someone else would like to review/test before changing to RTBC.
Comment #66
badrange commentedFix a typo in the patch,
@return stringe->@return string.Note: I was wrong in my last comment, the deprecation change I thought I added here has already been committed to Drupal Core in #2691675, the test failures happened because the patch did not have that deprecation change in it. This problem wouldn't have happened if we were using pull requests.
Comment #67
badrange commentedComment #68
badrange commentedAttaching a patch with the fix for 8.7.x too.
Comment #69
hugovk commentedConfirmed patch #68 works with Drupal 8.7.5. Thanks!
Comment #70
jonathanshawNice to see this coming along.
We need an issue summary update, change record and follow up, so NW by definition.
Comment #71
badrange commentedAttempting to update issue title and summary. Feedback welcome.
Comment #72
hugovk commented@badrange Thanks for updating the title and summary! I've removed the "Needs issue summary update" tag.
@jonathanshaw Please can you point us towards what's needed for a change record? And what does "needs followup" need, specifically?
Comment #73
jonathanshaw@hugovk see #49 and https://www.drupal.org/contributor-tasks/draft-change-record
Comment #74
dpiThis is all about breadcrumbs.
Comment #75
hugovk commentedThanks, added a draft change record: https://www.drupal.org/node/3075372.
What's next?
Comment #76
badrange commentedSetting this to RTBC because this issue has already been set to RTBC in #14, #56 and #69. The patch has also been confirmed to work in #65, and the issue summary has been updated and a change record created as requested in #70.
Comment #77
badrange commentedBefore anybody complains about the patch not fixing the bug with outdated breadcrumbs after editing username, here is a fix for 8.8.x with interdiff.
Comment #78
jonathanshawUser fix looks good.
Follow-up created:
#3075840: Consider deprecating TitleResolver::getTitle()
Comment #79
larowlanDo we need this as part of the API? I don't think we do - the only two calls are immediately after a call to new CacheableTitle, should we just make the constructor require a title instead?
Less api to maintain then
I don't think we need the & here, objects are always passed by reference
same here for the &
Are we sure this doesn't force the title to vary on each page its generated on?
e.g. we generate a title for a breadcrumb in multiple places - if we cache by route does that mean we're not re-using?
e.g
node/1/edit
node/1/revisions
Does the title resolved for node/1 get recalculated on both pages because the route is different?
can we use willReturnMap here instead of ->at, at is brittle - or even willReturnCallback
actually, we return the same thing both times, so do we even need the at() calls?
Comment #80
badrange commentedHi larowlan and thank you for the feedback! Here is an updated patch with some responses to your comments, and two more issues added as a bonus.
Note that I have added a new patch, 81, with interdiff from both 80 and 77 for your convenience (regarding constructor).
core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.phpthe tests will fail. So I'm stuck with this too.
Oops the parameter was missing from the docblock
Ouch, we hadn't updated the parameter in the docblock
Oh my this is also a problem with term entities. And so far I haven't figured out how to fix it, but this will at least make the tests fail until we nail this. Any pointers?
Comment #81
badrange commentedI added a solution for 1, I hope you intended something like this.
Comment #84
larowlanReplies:
1) yep, that's what I meant, do it in the constructor 😎
4) I'd ask for assistance from @WimLeers, I'll ping him in slack for his input
5) just remove the with() from both? it always returns the same thing regardless, so I think that is fine
Good catch on the terms, haven't looked into where to fix that yet.
Comment #85
jibran4.
'url.path.parent'might work.Comment #86
badrange commented1,2,3 should be ok
4) Waiting to hear from WimLeers or others. I'm in the Drupal Slack under the same handle as here, badrange
5) Was this how you meant? (see attached patch + interdiff). There was no need for two titleresolver calls anymore after removing with. I really don't know what I'm doing here.
6,7 should be ok
8) What about creating a separate follow up issue for this, scope creep is the best way to ensure that this issue doesn't get merged before Greenland melts.
Comment #87
jonathanshaw#80.8
I think the relvant taxonomy code is in
core/modules/taxonomy/src/Controller/TaxonomyController.phpHowever, the problem goes far beyond taxonomy terms. In fact it seems to apply in most places that use title callbacks.
A few minutes searching for _title_callback led me to the following (at least) that depend on an entity and probably need to be adjusted for cacheability:
node/src/Controller/NodePreviewController::title
taxonomy\Controller\TaxonomyController::vocabularyTitle
node\Controller\NodeController::revisionPageTitle
filter\Controller\FilterController::getLabel
comment\Controller\CommentController::commentPermalinkTitle
menu_ui\Controller\MenuController::menuTitle
An interesting different case is
tracker\Controller\TrackerUserTab::getTitlewhich hasAll of this makes me wonder if the fix proposed here is too gentle, relies too much on developers opting in to it.
Could we instead or also intercept the title callback and ALWAYS add the first argument supplied to the callback method as a cacheable dependency? Developers would be free to remove the dependency in the vanishingly unlikely event it wasn't needed, but we wouldn't have hundreds of contrib modules forgetting to add it.
Comment #88
badrange commentedFirst: Thanks to jibran for the
'url.path.parent'suggestion, it seems to work!Second: I realised that the change in #81 where we removed setTitle() in favour of a constructor broke the patch: The title stopped updating itself. I reverted that change, and while looking into this realised that the function
getCacheableTitleincore/lib/Drupal/Core/Controller/TitleResolver.phpwas actually callingdoGetTitlewith the parameters, so I updated the parameter naming and docblock for
doGetTitle().Why did the conversion from setTitle to __constructor break this? Well, for nodes as an example,
public function title()incore/modules/node/src/Controller/NodeViewController.phpadds a cacheable dependency on the node in question to $cacheable_metadata. If we use the constructor way, that information gets lost. I don't know what I'm doing wrong.Third: It does make sense to intercept the title callback as jonathanshaw proposes, although that probably requires comments and feedback from a lot more people (could there any bc breaks?). Wonder if it would be a good idea to split this into several steps so that we can move forward.
Comment #90
wim leers#79.4 wrote:
4 years and 9 days ago, #2483183: Make breadcrumb block cacheable introduced
class Breadcrumb implements RenderableInterface, RefinableCacheableDependencyInterface, which brought cacheability to breadcrumbs 😊 #2699627: url.path cache context for breadcrumbs is unnecessarily granular improved its cacheability.That same issue made the different breadcrumb builders associate different cacheability, based on their strategy:
\Drupal\book\BookBreadcrumbBuilderassociates theroute.book_navigationcache context (because it applies only toNoderoutes that are part of books) and the cache tag of the book\Drupal\taxonomy\TermBreadcrumbBuilderassociates theroutecache context (it applies only to canonicalTermroutes) and the cache tags of each term in the lineage\Drupal\system\PathBasedBreadcrumbBuildercan be used for any route: like it's name says, it's only path-based. Hence it varies byurl.path.parentandurl.path.is_frontplus whatever cacheability route access returnsI'm surprised by the bug report and its steps to reproduce, because
PathBasedBreadcrumbBuilderdoes this:and while the title indeed doesn't carry cacheability (and this is indeed a problem), the
$accessalone should still have the node's cache tag. Every node save, for a new revision or not, triggers an invalidation of the node's cache tag. Yet that is somehow insufficient here. Why is that?! 🤔🤔 Can a title also contain attachments, such as assets or HTTP response headers? I don't think so?
Hence I think this should
implement CacheableDependencyInterfaceanduse CacheableDependencyTrait.Let's name this
$cacheabilityinstead, like we do in many places. Related: #2561773: CacheableMetadata is misnamed.Also, let's typehint to
RefinableCacheableDependencyInterface, not to a concrete class.🤔 Ideally, we'd typehint to
CacheableDependencyInterfaceinstead of what I wrote in the previous bullet, but this makes that impossible. And this is what I was asked to investigate.Every title is dependent on the route it's being generated for. But the code computing a title is not asked to compute a title for many things; it is always given a concrete route match already.
Cacheability metadata (https://www.drupal.org/docs/8/api/cache-api/cache-api#cacheability-metadata) is meant to indicate that given a certain input, what variations of the input cause a different output. Varying by
routeonly makes sense if the input consists of multiple routes. That's not the case here.The path-based breadcrumb builder is what should be doing the necessary varying. And there is a known bug there, that has not seen much movement because clear steps to reproduce are missing: #2719721: BreadcrumbBuilder::applies() mismatch with cacheability metadata. I think this line may be necessary here because that issue has not yet been fixed. Let's fix that first? :)
Instead of receiving an optional object by reference, only to modify it to pass out-of-band information as a side effect, I think it would be better to follow the pattern that
\Drupal\Core\Access\AccessibleInterface::access()also uses: a$return_as_objectboolean, defaulting toFALSE, but when opting in to this by passingTRUEinstead, it would make this code return aCacheableTitleobject.Comment #91
jonathanshawLooks like intercepting the title callback might be straightforward: in
TitleResolver::doGetTitle()maybe we could do something like:And this seems not unreasonable because the arguments here are not specified by the caller but instead are requested by the callback provider; if a method is requesting an argument then it seems reasonable to assume that the title it calculates varies depending on the arguments is has requested.
Comment #92
badrange commentedThank you for the extra information, Wim Leers, and for the feedback from you and jonathanshaw. I checked out the 8.8.x branch on my machine, set some breakpoints and stepped through the code trying to figure out why the $access didn't carry the cache tag as it should, and started wondering if I was on to something when I encountered these lines of code in
core/modules/node/src/NodeAccessControlHandler.php'spublic function access():Neither AccessResult::allowed() nor cachePerPermissions() keep the $entity's cache tag right?
If I add (false &&) to the if so that the if always fails, the error goes away for nodes. If I log in as an editor without the bypass node access permission, the breadcrumb changes itself as it should.
The bug affects both my editor user and administrator/user 1 when editing terms and user accounts. Are we on to something here?
Comment #93
badrange commentedI want to be fully transparent: I'm not able to continue with this patch as I started in a new project at work. I hope (the magic) someone is able to pick up where I left off. I'm sorry about this, I wanted to get it all the way to the end but it turned out to be way out of my league.
Comment #94
larowlan@badrange - no need to be sorry - thanks for everything you've done so far! 94 comments indicates this isn't a simple fix, and you've keep this moving, someone else will pick up the baton from here
🏆
Comment #95
badrange commentedHere is a reroll of #88 after a change to function signature in core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
Poor man's interdiff:
I still hope "someone" will be able to take Wim Leers comments in #90 and jonathanshaw's in #91 into account.
Comment #97
geaseThe patch from #95 wasn't applicable, so a simple reroll.
Comment #98
geaseFixed unit test.
Comment #99
hchonov@Wim Leers, I just checked what happens in
\Drupal\Core\Access\AccessManager::check()when called from within\Drupal\system\PathBasedBreadcrumbBuilder::build()during the generation of the breadcrumb on the term/edit page. See the screenshot from the debugger. It looks like the term/view is represented by a view (views.view.taxonomy_term) even though it has also an own route in case views is not installed. The view itself has only a permission access, which is the reason why the access result does not carry any term cacheability metadata. I am not familiar with views to comment on our possible options from here.Here is the screenshot:

I've also managed to find out why the term breadcrumb test is failing. The usage post values variable was inconsistent in the test, but the most important part is that the title was retrieved through
\Drupal\taxonomy\Controller\TaxonomyController::termTitle(), which didn't had yet the new parameter$cacheable_metadata.I haven't fully reviewed the patch yet, but it would be great if we could think of a more general solution. I think that the current approach requires too much knowledge when defining a title callback.
Comment #101
pankaj.singh commentedComment #102
pankaj.singh commentedTested the patch given in #99 on 9.1.x-dev. It's working fine on my end.
Please refer to the SS for ref. RTBC+1.
Comment #103
tanubansal commentedI can't see breadcrumb via authenticated user
Any patch available for 9.1?
Comment #104
hugovk commentedHere's a reroll of #99 for Drupal 8.9.2.
Comment #106
hugovk commentedFixed re-roll of #99 in #104.
Comment #107
hugovk commentedComment #108
ayushmishra206 commentedComment #109
ayushmishra206 commentedTested the patch #106 on 8.9.x-dev. It's working fine, i am attaching screenshots.
Comment #110
ayushmishra206 commentedNeeds a reroll for 9.1.x-dev
Comment #111
ayushmishra206 commentedComment #112
hugovk commentedThank you for testing! Updating as RTBC.
Comment #113
jonathanshawThe discussion in #90 and #99 is not remotely resolved. The patch may seem to work, but there are major doubts about the correct approach.
Comment #114
ayushmishra206 commentedComment #115
larowlanTagging this for visibility
Comment #116
manish-31 commented@ hugovk patch #106 failed to apply while patch #99 applied successfully on my drupal 8.9.x site can you please let me know whether it is good to use #99 ? Thanks in advance!
Comment #117
hugovk commented@manish-31 We're using patch #106 on our 8.9.5 site, and it's applying successfully. I originally made #106 as a re-roll of #99 for 8.9.2 (most likely because #99 didn't apply for 8.9.2).
Comment #118
thallesAfter apply #114 my Drupal 8 environment broken.
Comment #119
thallesComment #121
larowlanComment #122
govind.maloo commentedReroll for 9.2.x
Comment #123
govind.maloo commentedComment #125
govind.maloo commentedComment #126
govind.maloo commentedComment #127
hershey.k commentedReroll for latest
9.1.x(9.1.3as of this writing). All previous patches from #106 have line conflicts in one of two test files.(Patch #114 is missing new Interface, hence error outlined in #118).
Comment #128
hershey.k commentedComment #129
hershey.k commentedComment #130
hershey.k commentedComment #131
hershey.k commentedComment #132
sker101 commented#131 works for me on 9.1.x branch
Moving it to RTBC
Comment #133
jonathanshawThe discussion in #90 and #99 is not remotely resolved. The patch may seem to work, but there are major doubts about the correct approach.
Comment #135
hershey.k commentedRe-rolling existing patch for latest stable 9.1.10 release.
Comment #136
rinku jacob 13 commentedVerified and tested patch#135 on the drupal 9.3.x-dev version. Patch applied successfully and looks good to me.Need +1 RTBC.
Comment #138
bhanu951 commentedSeems the patch is not working when there is a `_title_callback:` key in `*.routing.yml` title breadcrumb is not changed after title callback is changed.
Comment #139
bhanu951 commentedComment #142
ranjith_kumar_k_u commentedComment #145
penyaskitoRerolled #135. I worked against 9.4.x because that's what my project is using, so testing the patch against that for now.
I did a couple of changes, explained next comment.
Comment #146
penyaskitoI made the cacheable title resolver interface extend title resolver interface, to ensure we can replace that one without API changes.
We cannot change the interface being injected for BC, so we need this check here and if someone replaced the injected service use the previous getTitle method.
Simplified this clause.
I still think this needs work, as some namespaces don't make sense to me, but maybe only moving things around.
Comment #147
penyaskitoFixed code standards errors.
Comment #148
penyaskitoAnother code standards error.
Comment #150
penyaskitoThis was missing a use statement.
Comment #152
penyaskitoRemoved deprecations that made tests fail.
Comment #154
penyaskitoThe failure is a known random failure, so tests are green-ish.
This is a bug, so I think it can be targeted to 9.5.x
However, #90 and #99 still need to be addressed.
Comment #155
gustavowal commentedWe have the same issue on fairly recent built website with D9 from the get-go, this issue only seems to be happening when using render cache to cache.backend.memcache, this happens on both memcache 1.5 and 1.6 with default memcache parameters on AWS.
We tried patch #142 and #152, but without success.
The issue is very straightforward to replicate, on an admin logged session editing the title that also changes the breadcrumb and going to a non-logged session, the title will reflect the change and also the URL, but the breadcrumb will stay the same. Viewing the page on the logged-in session shows up the updated breadcrumb right away, due to logged-in not being cacheable.
Using telnet to login into the memcache instance and running a full flush (FLUSH_ALL) and refreshing the non-logged-in session, the breadcrumb will update to reflect the correct changes.
Using render cache set to cache.backend.memory or even cache.backend.null the issue is not present.
Comment #156
sker101 commentedRerolling #152 for Drupal 9.5.x
Comment #157
sker101 commentedFixes CS error, how was coding standard test passing with patch #152?
Comment #159
bhanu951 commentedRe Rolled MR #3196 for 10.x branch and added
TimeInterfaceargument for constructor and depreciation forREQUEST_TIME.Comment #160
bhanu951 commentedComment #161
bhanu951 commentedComment #162
bhanu951 commentedSeems the patch is not resolving the issue, I created a test controller based on #138 refer image below.
but the issue is not resolved. Still different breadcrumb than that of title.
Comment #163
smustgrave commentedMR has many test failures.
Also I tried to reproduce following the IS on Drupal 10 and was not able to replicate. Title updates just fine for me, but maybe it's just me. Will rely on the tests to prove me wrong.
Comment #164
bhanu951 commentedCreated a test fail patch based on #138 to prove issue exists.
Comment #165
smustgrave commentedAdded some feedback.
Rule of thumb I've been trying to use for new functions on interfaces or classes we should try to typehint.
Tests look good!
Comment #166
bhanu951 commentedFixed phpstan-baseline error in the fail test patch in #164.
Interdiff-164-166
Comment #167
bhanu951 commentedComment #169
bhanu951 commentedAs @gustavowal mentioned in #155
I think we need to update fail test patch to consider logged in user as well. Which is currently not included.
Comment #171
stomusicRe-roll for 10.2.x
Comment #172
sker101 commentedRerolling again for latest 10.2.x
Comment #174
bhanu951 commentedComment #175
bhanu951 commentedComment #176
sker101 commentedRecreated rerolling patch for 10.2.x since the "$title" property in the "CacheableTitle" class could be array type as well and throwing the error after adding the type hint.
Comment #177
brandonlira commentedI tested patch #176 for version 10.2.5 and it worked correctly.
Comment #178
bhanu951 commentedComment #185
ammaletu commentedThat this fundamental bug is still open after 9 years is... oh well. Are we all just using "Easy Breacrumb" which handles this correctly?
Looking at the MR, there is the request to add type hints in some places. Makes sense, I added the requested type hints. Looking at the code, I also wonder:
I could change the variable cases if somebody agrees this should be done. Then lets see what the pipeline says. I see the last run failed with stuff that has nothing to do with this MR (linting and spelling in JavaScipt files). Maybe somebody who knows how this works needs to merge the current 11.x state in here?!
Comment #186
sker101 commentedAdding a static patch file here for the latest merge request changes. The type declarations added from the previous merge request commits for the "$title" property was breaking our site because the property could also receive an array as its value.