Sending notification mail fails when CV is set
-
When I send the “apply to job” form
- without any file attached, submitting works correctly and the emails can be send.
- with only the job letter file set, the email is sent as well
- with only the cv file set, no email is sent and the server responds a
500
HTTP Status code.
The logs on the server report the following error:
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /var/www/html/wp-content/plugins/job-postings/include/class-job-posting-helper.php:223"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "Stack trace:"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#0 /var/www/html/wp-content/plugins/job-postings/include/class-job-posting-helper.php(223): strpos(Array, '/job-postings-g...')"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#1 /var/www/html/wp-content/plugins/job-postings/include/class-job-notifications.php(122): Job_Postings_Helper::getFilePath(Array)"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#2 /var/www/html/wp-content/plugins/job-postings/include/class-job-application-submit.php(553): JobNotifications::sendEntryEmail('5599', 6161)"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#3 /var/www/html/wp-includes/class-wp-hook.php(324): JobApplicationSubmit::ajax_submit('')"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#4 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#5 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#6 /var/www/html/wp-admin/admin-ajax.php(207): do_action('wp_ajax_nopriv_...')"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: "#7 {main}"
[29-Sep-2024 14:34:38] WARNING: [pool www] child 3907 said into stderr: " thrown in /var/www/html/wp-content/plugins/jo..."And this is the data send during the POST request:
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_job_fullname"
My Name
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_job_email"
[email protected]
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_job_phone"
0123456789
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_job_letter"; filename=""
Content-Type: application/octet-stream
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_job_cv-1"; filename="vds-1234.pdf"
Content-Type: application/pdf
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="input_honeypot"
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="action"
jobslisting_apply_now
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="language"
de
------WebKitFormBoundaryU8w9cyALY2VWQVkG
Content-Disposition: form-data; name="post_id"
5599
------WebKitFormBoundaryU8w9cyALY2VWQVkG--There are two problems:
- The obvious one: The sending of the notifications should not fail if the field
input_job_letter
has an empty value. - The frontend should report the error to the end user. Currently the loading spinner is shown indefinitely.
—
After some digging in the code I was able to narrow the issue:
Job_Postings_Helper::getFilePath
is called with the following array:Array
(
[label] =>
[value] => https://test.ddev.site/wp-content/uploads/2024/09/vds-1234-5.pdf
[path] => /var/www/html/wp-content/uploads/2024/09/vds-1234-5.pdf
)This leads to error.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.