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

---

Issue fork webform-3209749

Command icon 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

dev.tim created an issue. See original summary.

gooddev’s picture

StatusFileSize
new1.11 KB

Add patch for install-purposes...

jrockowitz’s picture

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

jrockowitz’s picture

Version: 6.0.2 » 8.x-5.x-dev
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new1.01 KB

Yep, 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_arg in the cache context.

jrockowitz’s picture

Status: Needs review » Needs work
StatusFileSize
new1.32 MB

Even 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?

jrockowitz’s picture

Ah!!! I was able to reproduce this issue in 6.x (not 8.x-5.x)

jrockowitz’s picture

StatusFileSize
new168.33 KB

This 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

jrockowitz’s picture

Status: Needs work » Closed (works as designed)
gooddev’s picture

thank you for the hint!