Problem/Motivation
Webform share module allows to embed webforms or also webforms entity-wrappers (like node). If both cases are embedded the dynamic generated script is cached, resulting in only one possible version, either webform standalone, or webform with entity source wrapper. To be able to serve both versions of webform via iframe we need to add an additional "CacheableDependency" to the script build rendering. Should be enough to add cache context for url parameters "source_entity_id" and "source_entity_type", because this are already used for embed webform via entity source wrapper like node.
Steps to reproduce
Enable webform share module and activate settings "share" and "share_node" on a webform. Share and embed example webform via sharing as standalone and as node-webform (create a node with selected example webform first). You should have some differences on you rendering-template for standalone and node-webform, otherwise the issue wouldn't show up. Now the result with enabled cache should be to only see the first visited version, the other version of the webform stays the same as the already cached one.
Proposed resolution
Add build render array as "CacheableDependency", because this already has the query string in it.
Remaining tasks
merge
User interface changes
---
API changes
---
Data model changes
---
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Screen Shot 2021-06-05 at 6.09.59 AM.png | 168.33 KB | jrockowitz |
| #7 | ScreenFlow.gif | 1.32 MB | jrockowitz |
| #6 | 3209749-6.patch | 1.01 KB | jrockowitz |
| #3 | 3209749-3-Webform-Share-Script.patch | 1.11 KB | gooddev |
Issue fork webform-3209749
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
gooddev commentedAdd patch for install-purposes...
Comment #4
jrockowitz commentedI have never added the entire render array as a dependency. Shouldn't we just add the query string parameters as cache dependency?
This issue should be resolved in 8.x-5.x first.
Comment #5
jrockowitz commentedComment #6
jrockowitz commentedYep, I now see the issue that you caught.
Because we call \Drupal\Core\Render\RendererInterface::renderPlain, the cache context for the query string is not being applied to the response.
For anyone interested in more information, @see https://www.drupal.org/docs/8/api/render-api/cacheability-of-render-arrays
With adding the render array to the response's cachable dependencies, as suggested in the previous patch, we also need to include the
url.query_argin the cache context.Comment #7
jrockowitz commentedEven though I understand the issue, I am not able to replicate it via the event registration system demo.
Below are the example URLs, I am using to confirm the event information is appearing via tokens on each shared webform node.
I think this source entity cache context is being picked up from the Webform.
@see \Drupal\webform\Entity\Webform::getCacheContexts
Can you provide an example webform with URLs? Is there specific token that is not working as expected?
Comment #8
jrockowitz commentedAh!!! I was able to reproduce this issue in 6.x (not 8.x-5.x)
Comment #9
jrockowitz commentedThis issue that I am seeing is fixed when 'Allow source entity to be populated using query string parameters' is checked via /admin/structure/webform/manage/{webform_id}/settings/form
Comment #10
jrockowitz commentedComment #11
gooddev commentedthank you for the hint!