-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi Philipp, I am opening this issues to make potential users aware that I've run into problems with newer versions of WP and HTMLForms, until we know that it would make sense to open a PR.
I cannot pinpoint a specific version of WP/HTMLForms because the error wasn't discovered for a long time in my deployment (6 Months and 600 failed submissions 😅)
PHP Fatal error: Uncaught TypeError: hf_replace_data_variables(): Argument #2 ($submission) must be of type HTML_Forms\Submission, array given
Quick fix
zammad-wp/includes/functions/hf-plugin-integration.php
Lines 206 to 225 in 2854267
| $subject = apply_filters( | |
| 'zammad_wp:hf_action:subject', | |
| hf_replace_data_variables($settings['subject'], $data, 'strip_tags'), | |
| $submission | |
| ); | |
| $message = apply_filters( | |
| 'zammad_wp:hf_action:message', | |
| hf_replace_data_variables($settings['message'], $data, 'esc_html'), | |
| $submission | |
| ); | |
| $attachments = apply_filters( | |
| 'zammad_wp:hf_action:attachments', | |
| zammad_hf_prepare_attachments($files), | |
| $submission | |
| ); | |
| $tags = apply_filters( | |
| 'zammad_wp:hf_action:tags', | |
| hf_replace_data_variables($settings['tags'], $data, 'strip_tags'), | |
| $submission | |
| ); |
Replace $data with $submission in the three function calls of hf_replace_data_variables:
hf_replace_data_variables($settings['subject'], $data, 'strip_tags') -> hf_replace_data_variables($settings['subject'], $submission, 'strip_tags')
My limited code review shows that the $data (Array) object is only used to extract information from the initial $submission (HTMLForms/Submission) object, but no data is being altered in $data - So it should be save to replace with $submission