Problem/Motivation
When adding flexmail handler errors are thrown upon submission. It appears FlexmailWebformHandler.php does not correctly reference properties coming from flexmail API.
Steps to reproduce
- Setup flexmail handler select "Update contact" and submit the webform. Error is thrown "There was a problem updating ... in Flexmail".
- Select "do no update existing contact" in webform handler settings, submit form. Error is thrown "Can not create or retrieve user with email"
Proposed resolution
For the first issue (Updating contact):
The API return data but with a 'total' property set to 0 if no results are found.
Here we can add a check on the 'total' property to allow pass through:
if (empty($contacts) || $contacts['total'] === 0) {
For the second issue (Default submission):
It appears the code is not correctly referencing the response returned from flexmail API.
Currently:
$contactArray = \reset($contacts);
Suggested:
$contactArray = $contacts['_embedded']['item'][0];
Flexmail API documentation:
https://api.flexmail.eu/documentation/?_ga=2.103788096.1348026172.166601...
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3315782-flexmail-not-matching-api-schema.patch | 1.29 KB | j1mb0b |
Issue fork flexmail-3315782
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
j1mb0b commentedComment #3
j1mb0b commentedComment #4
j1mb0b commentedComment #5
j1mb0b commentedPatch with updated changes.
Comment #6
j1mb0b commentedComment #8
daften commentedThis is in line with the changes in #3278677: Webform Handler can not load Handler Settings. It looks good and a quick test showed no issues after the patch, so commited. I'll release a new version asap. Thanks for the contribution!
I committed this, since it's completely broken without. But it requires an additional change. Due to the if ($contactArray) { that can fail, $contact_id could be null, there should be a safeguard for that in the code too.
Comment #11
matthijsA similar issue exists for the contact preferences and interests (I presumed the latter, didn't test/verified it). The MR resolves this.
Comment #15
daften commentedI incorporated that contribution in a new release Matthijs, thanks. Putting back to needs work for the edge cases mentioned above.