Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Same thing as #2729211: node_query_node_access_alter() should only add cacheability on GET/HEAD.
In this case a URL was being generated for logging, but toString() was called without setting $collect_bubblable_metadata to FALSE, resulting in our favourite exception message.
Proposed resolution
Only collect bubbleable metadata if both the argument is set, and the method is safe. This is a behaviour change of course.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff-2744715.txt | 3.17 KB | trzcinski.t@gmail.com |
#18 | 2744715-18.patch | 5.09 KB | trzcinski.t@gmail.com |
#16 | interdiff-2744715.txt | 2.35 KB | trzcinski.t@gmail.com |
#16 | 2744715-16.patch | 5.09 KB | trzcinski.t@gmail.com |
#12 | 2744715.patch | 2.74 KB | catch |
Comments
Comment #2
catchUntested patch.
Comment #4
catchComment #5
catchComment #6
catchComment #7
dawehnerCan we add this check in \Drupal\Core\Render\MetadataBubblingUrlGenerator::bubble instead? That seems to be the better place to be honest
Comment #9
Wim Leers#7++
Comment #10
catchYes that's a lot better. No interdiff since completely different patch.
Comment #12
catchMissing use statement.
Comment #16
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com as a volunteer commentedHi. This patch still applies cleanly (checked against 8.4.x). Works great!
I have made the tests pass and added a safe / non-safe test cases (not sure if this is correct approach though).
Attaching the improved patch and the interdiff.
Comment #17
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com as a volunteer commentedRerunning the tests.
Comment #18
trzcinski.t@gmail.com CreditAttribution: trzcinski.t@gmail.com as a volunteer commentedSeems like he
isMethodSafe
is deprecated in this context? I have changed it toisMethodCacheable
which sounds like a real way to go. Interdiff attached again (with the @catch'es patch)Comment #19
dawehnerGood catch @tom_ek!
Comment #20
larowlannit: two blank lines - can be fixed on commit
Was there a reason that MetadataBubblingUrlGenerator decorated the base generator instead of extending it?
setContext, getContext, getPathFromRoute, supports and getRouteDebugMessage all defer to decorated, but could easily defer to parent. Then we could remove those methods.
generate and generateFromRoute add the bubble info, but could easily call parent::{method} instead of $this->urlGenerator.
If we did that, we'd have the request stack for free, because the base generator already has it injected.
Just a thought - could be a reason why we did it the way we did.
is there a reason why we changed the order of arguments here?
Comment #21
Wim LeersNote that this is being changed by #2367555: Deprecate EnforcedResponseException support + #2653998: Allow to opt-in for render caching on POST requests. Render caching will work for e.g. POST requests then. Because thanks to cache tags, we will know which parts of the page will have been invalidated. So using render caching will no longer need to be disabled for POST requests.
At minimum, this needs to reference those issues.