Problem/Motivation
This issue is spun off from #3038254-60: Delegate media library access to the "thing" that opened the library.
The MediaLibraryState object is the crucial link in the way the Media Library system is stitched together. It is used for access checking, selection handling, and the construction of the Media Library UI itself. For all these reasons, it makes sense for it to be able to influence caching, but currently it does not carry any caching information.
Proposed resolution
Implement CacheableDependencyInterface, and its accompanying trait, on MediaLibraryState.
Remaining tasks
Do that.
User interface changes
None.
API changes
None, really.
Data model changes
None.
Release notes snippet
Probably none. This is a change to internal plumbing.
Comment | File | Size | Author |
---|
Issue fork drupal-3063343
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
Comment #2
phenaproximaInitial patch.
Comment #3
borisson_This look good apart from the missing test coverage, +1.
Comment #4
xjmThis is probably at least a major task. :)
Comment #6
Wim LeersThis was opened in response to @effulgentsia's review at #3038254-60: Delegate media library access to the "thing" that opened the library. Crediting him.
This is not major, and does not affect the cacheability of any response. @effulgentsia merely pointed out that hardcoding some cache context is not semantically ideal, it'd be better for the object that causes that cache context to be added to implement
CacheableDependencyInterface
so that the hardcoding can be removed.#2 should've removed the hardcoding, but did not yet. Also, this does not need test coverage. It's a pure refactoring.
Comment #7
phenaproximaI know I originally wrote it, but +1 RTBC here. It's absolutely pure refactoring and has pre-existing test coverage.
Comment #8
larowlanick - anyone know if we have an issue to avoid this dance? (unrelated to this patch of course)
Committed a19a380 and pushed to 8.8.x. Thanks!
Comment #10
Wim LeersNo, we don't, and we can't. The reason: we didn't want to require
AccessResultInterface
to implement(Refinable)CacheableDependencyInterface
. Put differently: we want code to be able to not care about cacheability of access result.Or, rather: that is what we wanted a few years ago. Perhaps we feel differently about it today.
Comment #11
jibranLet's create a follow up to discuss this. I do think we have evolved during this time.
Comment #13
phenaproximaWell, folks, this is some advanced issue necromancy.
The changes made in this issue appear to have been reverted by #2969678-63: Integrate Media Library with Content Moderation. I discussed with @seanB in Slack, who wrote that patch, and he suspects that the changes were reverted accidentally. That issue has no discussion about the refactoring done here, or indeed any reference to this issue. The reverted lines are also the kind of changes that committers could have easily mistaken for legitimate, especially since none of the committers involved in #2969678: Integrate Media Library with Content Moderation were involved in this one.
So I think his theory holds water. Big whoops.
Reopening this so that we can restore these changes to 8.9.x and 9.3.x (and ideally 9.2.x), exactly as they were.
Comment #14
phenaproximaRemoving patches.
Comment #15
phenaproximaAnd, boom. I think this will apply to all target branches, but let's run tests to confirm.
Comment #16
starshapedLGTM! Flipping to RTBC.
Comment #17
larowlanWhen wouldn't this be an instance of RefinableCacheableDepdenencyInterface?
The fact this got reverted by accident indicates it probably should have had a test in the first instance.
Let's add one now to prevent a repeat regression.
Comment #18
larowlanAnswer to my comment above is in #10
Comment #19
seanBTo be fair, the accidental revert in my patch would have probably reverted any tests as well. I think I forgot to git pull before creating the patch that reverted it, and somehow we all overlooked the changes.
Comment #20
phenaproximaTrue, but "loss of test coverage" is something that always raises committer eyebrows, so IMHO @larowlan is correct that having test coverage would have increased its chances of being caught. :)
Comment #21
phenaproximaComment #23
phenaproximaWrote test coverage and switched to a merge request.
The thousandth merge request, in fact. 🥳 😎 🤓 There's something poetic about MR #1000 being a 2+ year-old issue that had to be resurrected due to an accidental revert. Maybe it's a good sign.
Anyway...removing the "needs tests" tag. Let's get this in.
Comment #24
seanBAgreed, test seems pretty straightforward. Back to RTBC!
Comment #26
catchCommitted 9674e3a and pushed to 9.3.x. Thanks!
We're in a mini-freeze for 9.2.x a the moment due to the patch release, so leaving RTBC for backport.
8.9.x is security-only now so this won't get backported there.
Comment #28
catchCherry-picked to 9.2.x.