Problem/Motivation

The webform handler tokens will attempt to substitute with any value type as a string, including arrays, as long as the key exists in the response data array.

See https://git.drupalcode.org/project/webform/-/blob/c88d021ce517daab0adf1b...

The result of referencing an array is a PHP notice and the string "Array" being returned by the token.

Proposed resolution

Add a simple is_string check for $value in the ternary:

See https://git.drupalcode.org/project/webform/-/blob/c88d021ce517daab0adf1b...

This will allow the use of token facilities for empty strings (e.g. [webform:handler:remote_post:completed:foo:clear]

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bighappyface created an issue. See original summary.

bighappyface’s picture

Status: Active » Needs review
FileSize
5.89 KB

I decided to use is_scalar instead to better-handle other types (e.g. integers) that can be easily coerced to strings.

  • bighappyface authored f180fa3 on 8.x-5.x
    Issue #3135006 by bighappyface: Webform Handler Token String Conversion...
jrockowitz’s picture

Status: Needs review » Fixed

Patch looks good. Thanks.

bighappyface’s picture

Status: Fixed » Closed (fixed)

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