In working with tokens, I found a few issues:

1) webform.tokens.inc, webform_token_info() contains:

  $webform_submission['view-url'] = [
    'name' => t('Update (token) URL'),
    'description' => t('The URL that can used to view the webform submission. The webform must be configured to allow users to view a submission using a secure token.'),
  ];

The name is obvious wrong. Should probably be "View (token) URL" or similar.

2) WebformSubmission::getTokenURL() has an inconsistency. For view, it returns a relative URL, but for update it returns an absolute URL (because it calls getSourceUrl() and that's what it returns. For consistency, the view case should probably be:

        $uri = $request_handler->getUrl($this, $this->getSourceEntity(), 'webform.user.submission')->setOption('absolute', TRUE);

... where the ->setOption('absolute', TRUE) is my suggested change.

3) I went through some effort to add the standard URL token modifiers to the view-url, update-url, and source-url tokens so that I could specify [webform-submission:view-url:absolute]. However if the change to 2 is made, then this probably isn't necessary or needed by anyone. The use case for absolute url's is to include them in webform email handler email messages. I will post a patch for the work I did just to preserve it for anyone else that might want it. I'm NOT suggest this be tested and committed. I am personally not using these tokens as I want ones without the URL query token ?token=xxx. (Confusing using token in two different means here.)

Comments

DanChadwick created an issue. See original summary.

danchadwick’s picture

Here's a patch for issue 3 for anyone in the future to use or build off of. Again, not suggesting issue 3 be worked on by maintainers.

I could make patches for issues 1 and 2, but they are trivial so I won't unless asked.

jrockowitz’s picture

Wow! That is an awesome improvement. I will review the patch in-depth when I have some time available.

jrockowitz’s picture

StatusFileSize
new3.73 KB

I agree with 2) and the view-url token is a new feature that has not been shared in a stable release.

The attached patch changes $uri to $url and moves the more complex URL tokens processing after the entity token.

jrockowitz’s picture

Status: Active » Needs review
jrockowitz’s picture

StatusFileSize
new3.76 KB

Just fixing the typo in the view-url token.

danchadwick’s picture

Not seeing that you've addressed issue 2 (inconsistent results of view versus update in getTokenUrl). Maybe this was intentional?

jrockowitz’s picture

2) is addressed by $options = $url->setAbsolute()->getOptions();.

I still need to add some basic test coverage.

jrockowitz’s picture

StatusFileSize
new6.58 KB

The attached patch adds some very basic test coverage.

danchadwick’s picture

Status: Needs review » Reviewed & tested by the community

Oh, gotcha. Didn't see that there. +1

I have read over the patch and it looks good to me. I have not conducted any manual testing, so I'm relying upon the code review and limited automated test coverage in doing so.

  • jrockowitz authored 4bd9573 on 8.x-5.x
    Issue #3094014 by jrockowitz, DanChadwick: Submission token description...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

I committed the patch.

What I like about tokens is generally they either work as expected or they don't

Status: Fixed » Closed (fixed)

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