Problem/Motivation
I noticed that empty token placeholders are not being removed from the email subject and body text. Since it can be be difficult to predict when optional field values are set on an entity, it seems like removing the empty tokens is a good default.
Steps to reproduce
- Create a workbench email with a token in the subject and message that is known to NOT exist.
- The sent email will not have the [***] token placeholders removed.
Proposed resolution
Pass the ['clear' => TRUE] option to the $this->token->replace method.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3202910-8.patch | 6.09 KB | pcate |
Issue fork workbench_email-3202910
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 #3
larowlanCode changes look great, we've got some existing tests for tokens, are you able to add in a case with an obvious broken token and assert it is removed?
See
\Drupal\Tests\workbench_email\Functional\WorkbenchEmailTestBase::testEndToEndComment #4
larowlanComment #8
pcate commentedI updated the
\Drupal\Tests\workbench_email\Functional\WorkbenchEmailTestBase::testEndToEndby added to the subject and body a non-existent token. The tests fail without the['clear' => TRUE]change.I had trouble finding out how to get drupal ci to run on the latest merge request so I just created a regular patch file. Sorry for the GitLab comment noise.
Comment #9
larowlanAwesome will make a new release with this on Monday
Comment #11
larowlanChanged on commit to add another instance mid-line to ensure spacing is retained
This will go out as 2.1.1