Problem/Motivation
When using webform field to embed a webform on another entity, query parameters are ignored for render caching. I switched back to version 5.25 which doesn't have the issue.
Steps to reproduce
- Create webform field on entity
- Use webform (webform_entity_reference_entity_view) field formatter
- Create entity & link a webform
- Update one of the webform fields to use a query parameter as default value: [current-page:query:name:clear]
- View the newly created entity (it does work when viewing the webform itself) as an anonymous user and change the query parameter a couple of times
Proposed resolution
/
Remaining tasks
/
User interface changes
/
API changes
/
Data model changes
/
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | 3211328-8.x-5.x-27.patch | 14.87 KB | jrockowitz |
| #27 | 3211328-8.x-5.x-27.patch | 14.87 KB | jrockowitz |
| #25 | 3211328-8.x-5.x-25.patch | 14.85 KB | jrockowitz |
| #24 | 3211328-24.patch | 14.81 KB | jrockowitz |
| #21 | 3211328-21.patch | 7.49 KB | jrockowitz |
Comments
Comment #2
jrockowitz commentedI think this regression was cause by #3110680: Leaked metadata error being thrown when creating a webform submission via GraphQL mutation
Comment #3
jrockowitz commentedI think we have to track the CacheableMetadata::applyTo and use CacheableMetadata::applyTo to apply the '#cache' properties to each element.
This somewhat is happening via \Drupal\Core\Utility\Token::replace
This change could be backported to 8.x-5.x.
Comment #4
jrockowitz commentedI am not able to replicate this issue using the attached webform in Drupal 8/9 with Webform 6.x.
Are you able to replicate this issue using the attached webform?
Can you provide the steps required to reproduce this issue? Maybe a certain cache-related module is enabled.
The attached patch is an educated guess on the solution, at the very least the patch documents the problem.
Comment #5
jrockowitz commentedThe failed tests seem unrelated to the patch.
Comment #6
jrockowitz commentedComment #7
jrockowitz commentedIn 6.x we are allowing anonymous webforms to be cached which is exposing this issue.
The cache tags and contexts need to be merged.
Comment #10
jrockowitz commentedComment #11
jrockowitz commentedI am able to reproduce this issue via Webform 6.x using the example webform when it is added to a webform node.
Comment #12
jrockowitz commentedThe attached patch catches the lost bubble metadata which is required to fix the caching issue.
Comment #13
jrockowitz commentedNote to self: To merge bubbleable metadata we can use or copy \Drupal\Core\Render\Renderer::mergeBubbleableMetadata.
Comment #14
jrockowitz commentedBecause the error is only occurring via 6.x, let's focus the patch on 6.x and backport it to 8.x-5.x
Comment #15
jrockowitz commentedAttached is what I feel might be the most reliable solution.
We still need to add test coverage to \Drupal\webform\Cache\WebformBubbleableMetadata and I think we might want to create a dedicated WebformSubmissionFormCacheTest that checks the $form and $element #cache property.
We can probably copy and modify. \Drupal\Tests\Core\Cache\CacheableMetadataTest
Comment #18
jrockowitz commentedComment #21
jrockowitz commentedComment #24
jrockowitz commentedThe attached patch now has test coverage and hopefully, it can be backported to 8.x-5.x.
Comment #25
jrockowitz commentedComment #27
jrockowitz commentedComment #28
jrockowitz commentedComment #31
jrockowitz commented