Here's the code:
function webform_replace_url_tokens($redirect_url, $node = NULL, $submission = NULL) {
// Parse the url into its components.
$parsed_redirect_url = drupal_parse_url($redirect_url);
// Replace tokens in each component.
$parsed_redirect_url['path'] = webform_replace_tokens($parsed_redirect_url['path'], $node, $submission);
if (!empty($parsed_redirect_url['query'])) {
foreach ($parsed_redirect_url['query'] as $key => $value) {
$parsed_redirect_url['query'][$key] = trim(webform_replace_tokens($value, $node, $submission));
}
}
...
As you see, this code always expects $value to have the string type. However, it can be an array (of arrays) of strings. For example, if the redirect url is something like this:
fillpdf?fid=23&webform[nid]=value1&webform[sid]=value2
This can be tested by setting the "Redirection location" field to "Custom URL" on page node/*/webform/configure and the custom url value to the string above. This will produce the following errors on submitting the form:
Warning: trim() expects parameter 1 to be string, array given in webform_replace_tokens() (line 3855 of sites/all/modules/contrib/webform/webform.module).
Warning: trim() expects parameter 1 to be string, array given in webform_replace_url_tokens() (line 3940 of sites/all/modules/contrib/webform/webform.module).
Issue fork webform-2637520
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 #2
wizonesolutionsThis is still an issue in 7.x-4.19.
Comment #3
Liam MorlandComment #4
Liam MorlandThis patch makes webform_replace_url_tokens() recursively handle arrays as input. I would appreciate a second set of eyes reviewing this code.
Comment #5
wizonesolutionsThis code looks fine to me, and it's been some time. Queued up some re-tests, consider it +1 from me if tests pass.