Problem/Motivation
When a menu has a link to a webform path, the whole menu will vary in cache by "url.path" context.
This occurs because of the access check on the link path which add a dependency to the webform entity : https://git.drupalcode.org/project/webform/-/blob/8.x-5.x/src/Access/Web....
The webform entity has a "url.path" context https://git.drupalcode.org/project/webform/-/blob/8.x-5.x/src/Entity/Web... so this context end on the whole menu render array cache context.
On a website with 30 000 pages, the render of menu will have 30 000 duplication in cache for the same content.
Steps to reproduce
- Create a webform with a path like /form/contact
- Add a link in the main menu to /form/contact
- Look at the menu cache entry with the cid "entity_view:block:[menuname]" and see that it has a cache context "url.path"
Proposed resolution
I'm not sure how to fix this but I guess the access check on the link path should not inherit the webform entity cache context.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3194569-8.x-5.x-5.patch | 1.64 KB | jrockowitz |
| #5 | 3194569-6.x-5.patch | 1.65 KB | jrockowitz |
| #2 | 3194569-2.patch | 622 bytes | jrockowitz |
Comments
Comment #2
jrockowitz commentedI might have gone overboard via #2902180: Webform with token_update enabled should bypass general access controls and the url.path cache context is not needed.
Comment #3
jrockowitz commentedI think we might be able to commit this patch because of #3211328: Webform field ignoring query parameters for render caching.
It is possible that all the cache contexts in \Drupal\webform\Entity\Webform::getCacheContexts should be moved to \Drupal\webform\WebformSubmissionForm::buildForm
Comment #5
jrockowitz commentedComment #8
jrockowitz commentedComment #9
jrockowitz commented