Skip to content

Uncaught Type Error #47

@terdinatore

Description

@terdinatore

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

$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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions