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
Coming from #2663638: Avoid checking the render context to detect early rendering for Non-GET requests. and #2729137: NodeStorage::loadByProperties should avoid adding node access query tags.
The check for a render context isn't really sufficient, we can also check isMethodSafe() and skip adding metadata there.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2729211.patch | 682 bytes | catch |
Comments
Comment #2
catchComment #3
catchComment #4
dawehnerI totally agree that it doesn't make sense to add them here. If we don't render cache, we don't need them anyway here.
Comment #6
catchComment #7
catchComment #8
catchComment #9
Wim LeersLet's also update the comment then. Can be done upon commit.
Comment #10
Wim LeersHowever … in
\Drupal\Core\Render\RenderCache::get()
+\Drupal\Core\Render\RenderCache::set()
:Doing this issue means that solving #2367555: Deprecate EnforcedResponseException support alone will not be enough to allow render cache to be used on POST requests. Which means we won't be able to use render cache for POST requests (i.e. when submitting a form) for things that are not affected until D9. That's probably a fine compromise, but I do want to call it out.
Comment #11
catchIf we do #2503429: [PP-*] Allow both AJAX and non-AJAX forms to POST to dedicated URLs then we won't render pages to find forms - this is the most expensive part of form submission. After the form submit we usually redirect, so there'll be no rendering of a page at all - POST -> submit -> RedirectResponse
Logging, e-mail sending etc. might happen as a result of form submission, but we don't need to enable render caching for those.
In irc Wim mention a POST -> submit -> render page flow. I hadn't thought about doing that, but if we did we could revisit all this then. For now I think it's consistent with the overall direction everything's taking.
Comment #12
Wim Leers+1
RTBC++
Comment #13
alexpottWhat about form validation errors?
Comment #14
catchThat's a good question. We'd either have to render the form with the validation errors at the dedicated URL we posted to (so render HTML on POST still), or use form storage, redirect back to the form URL itself as a GET request and show the errors there.
In terms of this issue, it only affects whether we do render caching on those post requests (if we have them), not anything else about changing the form submission process. So for me it's fine to change this now, then revisit if we need to when we get to that point.
Comment #15
alexpottCommitted cb80d54 and pushed to 8.1.x and 8.2.x. Thanks!