Closed (fixed)
Project:
Moderation Sidebar
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Feb 2019 at 03:24 UTC
Updated:
17 Mar 2019 at 23:29 UTC
Jump to comment: Most recent
Comments
Comment #2
berdirDoing this with a cacheability object makes it a bit complicated due to the many early returns. Wondering if the code would be easier if we'd refactor it to only have a single return and invert/nest the different checks, but that might have its own drawbacks. This is going to conflict with #2988331: Content translation moderation already now quite a bit and that refactoring would obviously make it worse.
Not 100% sure if it's better to placeholder this or just cache it. I guess if it is indeed just the route cache context and $entity as the cacheable dependency then it should be OK since this currently doesn't do any access checks or other more dynamic things (like checking if there are any local tasks). So, seems like a good idea to do this now and keep the placeholdering issue open as an option if we need to add more contexts.
Comment #3
dpiThanks @Berdir, I agree the many early returns are ugly, the whole function needs a bit of cleanup for readability. But also dont want to be disruptive if another issue is touching these LOCs.
So far the patch is working well on a pre-prod environment.
Comment #4
dpiCreds
Comment #5
berdirUpdating the issue title, because what you are describing is a problem with your custom hook and doesn't happen with just moderation sidebar IMHO. The problem is that it is completely uncacheable right now :)
I just tried and the patch in fact seems to not conflict with my issue, which is surprising. I was going to upload a patch that keeps the array cacheability definition on top and just adds a single line to do this:
CacheableMetadata::fromRenderArray($items['moderation_sidebar'])->addCacheableDependency($entity)->applyTo(...);
But since it doesn't conflict, waiting with that for now, lets see what the maintainer thinks.
Comment #6
berdirDid a retest to make sure this still works with the new tests, we're doing quite a few variations there with different nodes, so I think if we have bugs it should fail now. If not then this can be committed IMHO.
Note that the effect of this might not be immediately visible without #2914110: Shortcut hook_toolbar implementation makes all pages uncacheable in manual testing. But either without the shortcut module or with that patch, it should be possible to see that the dynamic page cache header goes to HIT/MISS with this instead of UNCACHEABLE.
Might also be possible to specifically test that, didn't check that yet.
Comment #8
samuel.mortensonLooks good to me - I think we can trust the current test coverage and add more if this causes any regressions. Thanks all!