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

  1. Create a webform with a path like /form/contact
  2. Add a link in the main menu to /form/contact
  3. 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.

Comments

Nixou created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new622 bytes

I 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.

jrockowitz’s picture

I 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

Status: Needs review » Needs work

The last submitted patch, 2: 3194569-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB
new1.64 KB

  • jrockowitz authored 6b46e7f on 8.x-5.x
    Issue #3194569 by jrockowitz: Any menu with a link to a webform will...

  • jrockowitz authored 6b46e7f on 6.x
    Issue #3194569 by jrockowitz: Any menu with a link to a webform will...
jrockowitz’s picture

jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.