PHP Fatal error: Uncaught TypeError: trim()
-
Using php8.1 along with the Constant Contact integration that comes with CF7.
I am getting the below error when attempting to submit a form where I have a select in use so users can select their state instead of typing it in. I have copied/pasted that input below. When the data is posted to the server, the your-address-state is posted as a string. When CF7 is processing the data to create the $submission->posted_data in at about /includes/submission.php:319 that string is converted into an array with
$value = (array) $value;
. Later on down the line the Constant Contact module calls the add_street_address function where the error occurs.In the interim, I will probably just allow users to type in their state or rollback to a previous version of php.
[select* your-address-state include_blank "Alabama""Alaska""Arizona""Arkansas""California""Colorado""Connecticut""Delaware""Florida""Georgia""Hawaii""Idaho""Illinois""Indiana""Iowa""Kansas""Kentucky""Louisiana""Maine""Maryland""Massachusetts""Michigan""Minnesota""Mississippi""Missouri""Montana""Nebraska""Nevada""New Hampshire""New Jersey""New Mexico""New York""North Carolina""North Dakota""Ohio""Oklahoma""Oregon""Pennsylvania""Rhode Island""South Carolina""South Dakota""Tennessee""Texas""Utah""Vermont""Virginia""Washington""Washington D.C.""West Virginia""Wisconsin""Wyoming"]
[26-Apr-2022 21:56:52 UTC] PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /home/site/public_html/wp-content/plugins/contact-form-7/modules/constant-contact/contact-post-request.php:282 Stack trace: #0 /home/site/public_html/wp-content/plugins/contact-form-7/modules/constant-contact/contact-post-request.php(282): trim(Array) #1 /home/site/public_html/wp-content/plugins/contact-form-7/modules/constant-contact/contact-post-request.php(86): WPCF7_ConstantContact_ContactPostRequest->add_street_address('', '', Array, '', '') #2 /home/site/public_html/wp-content/plugins/contact-form-7/modules/constant-contact/constant-contact.php(95): WPCF7_ConstantContact_ContactPostRequest->build(Object(WPCF7_Submission)) #3 /home/site/public_html/wp-includes/class-wp-hook.php(303): wpcf7_constant_contact_submit(Object(WPCF7_ContactForm), Array)#4 /home/site/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array) #5 /home/site/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Array)#6 /home/site/public_html/wp-content/plugins/contact-form-7/includes/contact-form.php(1055): do_action('wpcf7_submit', Object(WPCF7_ContactForm), Array) #7 /home/site/public_html/wp-content/plugins/contact-form-7/includes/rest-api.php(336): WPCF7_ContactForm->submit() #8 /home/site/public_html/wp-includes/rest-api/class-wp-rest-server.php(1140): WPCF7_REST_Controller->create_feedback(Object(WP_REST_Request)) #9 /home/site/public_html/wp-includes/rest-api/class-wp-rest-server.php(987): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/contact-form-7...',Array, NULL) #10 /home/site/public_html/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request)) #11 /home/site/public_html/wp-includes/rest-api.php(370): WP_REST_Server->serve_request('/contact-form-7...') #12 /home/site/public_html/wp-includes/class-wp-hook.php(303): rest_api_loaded(Object(WP)) #13 /home/site/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array) #14 /home/site/public_html/wp-includes/plugin.php(518): WP_Hook->do_action(Array) #15 /home/site/public_html/wp-includes/class-wp.php(388): do_action_ref_array('parse_request', Array) #16 /home/site/public_html/wp-includes/class-wp.php(750): WP->parse_request('') #17 /home/site/public_html/wp-includes/functions.php(1291): WP->main('') #18 /home/site/public_html/wp-blog-header.php(16): wp() #19 /home/site/public_html/index.php(17): require('/home/site...') #20 {main} thrown in /home/site/public_html/wp-content/plugins/contact-form-7/modules/constant-contact/contact-post-request.php on line 282
- The topic ‘PHP Fatal error: Uncaught TypeError: trim()’ is closed to new replies.