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

/

Comments

bceyssens created an issue. See original summary.

jrockowitz’s picture

jrockowitz’s picture

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

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new1.28 KB
new4.73 KB

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

jrockowitz’s picture

The failed tests seem unrelated to the patch.

jrockowitz’s picture

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

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.84 KB
new1.86 KB

In 6.x we are allowing anonymous webforms to be cached which is exposing this issue.

The cache tags and contexts need to be merged.

The last submitted patch, 7: 3211328-6.x-06.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 7: 3211328-8.x-5.x-06.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.84 KB
new1.85 KB
jrockowitz’s picture

I am able to reproduce this issue via Webform 6.x using the example webform when it is added to a webform node.

jrockowitz’s picture

StatusFileSize
new4.35 KB

The attached patch catches the lost bubble metadata which is required to fix the caching issue.

jrockowitz’s picture

Note to self: To merge bubbleable metadata we can use or copy \Drupal\Core\Render\Renderer::mergeBubbleableMetadata.

jrockowitz’s picture

Version: 8.x-5.x-dev » 6.x-dev

Because the error is only occurring via 6.x, let's focus the patch on 6.x and backport it to 8.x-5.x

jrockowitz’s picture

StatusFileSize
new7.49 KB

Attached 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

Status: Needs review » Needs work

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

  • 36850aa committed on 3211328-caching
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new7.49 KB

Status: Needs review » Needs work

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

  • 7e9d13c committed on 3211328-caching
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new7.49 KB

  • f8bd185 committed on 3211328-caching
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...

  • 7a024dd committed on 3211328-caching
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...
jrockowitz’s picture

StatusFileSize
new14.81 KB

The attached patch now has test coverage and hopefully, it can be backported to 8.x-5.x.

jrockowitz’s picture

StatusFileSize
new14.85 KB

Status: Needs review » Needs work

The last submitted patch, 25: 3211328-8.x-5.x-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new14.87 KB
jrockowitz’s picture

StatusFileSize
new14.87 KB

  • jrockowitz authored a7d4ffd on 8.x-5.x
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...

  • jrockowitz authored a7d4ffd on 6.x
    Issue #3211328 by jrockowitz: Webform field ignoring query parameters...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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