Skip Navigation

Resolved

Reported for: WPForms Multilingual 0.3.0

Resolved in: 0.3.1

Topic Tags: Compatibility

Overview of the issue

If you have a form with checkboxes created with WPForms plugin running under a PHP 8x server, it won’t work when you try to submit it. Instead you will have this fatal error:

[14-Feb-2023 18:43:45 UTC] PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #1 ($key) must be a valid array offset type in …/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Obj.php:98Stack trace: #5 …/wp-content/plugins/wpml-wpforms/classes/Hooks/WpForms/Strings.php(191): WPML\FP\Obj::__callStatic(‘propOr’, Array)#6 [internal function]: WPML\Forms\Hooks\WpForms\Strings->WPML\Forms\Hooks\WpForms\{closure}(Array, 44)#17 …/wp-content/plugins/wpml-wpforms/classes/Hooks/WpForms/Strings.php(197): WPML\FP\Obj::__callStatic(‘over’, Array)#18 …/wp-includes/class-wp-hook.php(308): WPML\Forms\Hooks\WpForms\Strings->translateEntry(Array, Array)

Workaround

Please, be sure to make a full backup before proceeding.

  1. Open the …/wp-content/plugins/wpml-wpforms/classes/Hooks/WpForms/Strings.php file.
  2. Look for line 185.
  3. Replace:
    			if ( in_array( Obj::path( [ 'fields', $fieldId, 'type' ], $originalForm ), [ 'checkbox', 'radio', 'select' ], true ) ) {
    

    With:

    			if ( in_array( Obj::path( [ 'fields', $fieldId, 'type' ], $originalForm ), [ 'radio', 'select' ], true ) ) {
    
    

19 Responses to “WPForms - PHP 8x - Issue submitting a form with checkbox fields”

  1. Hello,

    As wordpress don’t send any email alert with this fatal error, priority is Nr 1.
    How many form entries has been lost for your users ?
    I guess that many of them don’t even know that their forms do not work anymore.

    It is maybe a good idea to inform your users by mail and publish an update as soon as possible.

    Regards,
    Dimitri

    • Thank you very much for your feedback Dimitri.
      We understand the importance of this situation and we are working to release a patch version for solving this issue very soon.
      We will keep this erratum updated.

    • Thank you for your feedback Amal, we are glad to know it worked.
      We are working to release a patch version for solving this issue soon.
      Regards

  2. This workaround does work for me as well. But I agree with Dimitri regarding the emergency to let your customers know about this issue…

    • Thank you for your feedback, we are glad to know that it worked for you.
      We will keep this erratum updated once the patch is release.

  3. Hello everyone,
    We just released WPForms Multilingual 0.3.1 that should solve this issue.
    Thank you for your help and feedback!

  4. Hello,

    I have a new FATAL ERROR with version 0.3.1.
    I guess it happens when wpforms try to send emails notfications with shortcodes like {field_id=”31″} in email fields.
    Forms are correctly stored in entries database but notifications emails are not sent.

    PHP Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in /var/www/visit/public/wp-content/plugins/wpforms/includes/emails/class-emails.php:639
    Stack trace:
    #0 /var/www/visit/public/wp-content/plugins/wpforms/includes/emails/class-emails.php(639): str_replace()
    #1 /var/www/visit/public/wp-content/plugins/wpforms/includes/emails/class-emails.php(354): WPForms_WP_Emails->wpforms_html_field_value()
    #2 /var/www/visit/public/wp-content/plugins/wpforms/includes/emails/class-emails.php(436): WPForms_WP_Emails->build_email()
    #3 /var/www/visit/public/wp-content/plugins/wpforms/includes/class-process.php(988): WPForms_WP_Emails->send()
    #4 /var/www/visit/public/wp-content/plugins/wpforms/includes/class-process.php(458): WPForms_Process->entry_email()
    #5 /var/www/visit/public/wp-content/plugins/wpforms/includes/class-process.php(109): WPForms_Process->process()
    #6 /var/www/visit/public/wp-includes/class-wp-hook.php(308): WPForms_Process->listen()
    #7 /var/www/visit/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
    #8 /var/www/visit/public/wp-includes/plugin.php(565): WP_Hook->do_action()
    #9 /var/www/visit/public/wp-includes/class-wp.php(797): do_action_ref_array()
    #10 /var/www/visit/public/wp-includes/functions.php(1332): WP->main()
    #11 /var/www/visit/public/wp-blog-header.php(16): wp()
    #12 /var/www/visit/public/index.php(17): require('...')
    #13 {main}
    thrown in /var/www/visit/public/wp-content/plugins/wpforms/includes/emails/class-emails.php on line 639

    • Thank you very much for your report, Dimitri.
      I see that Nigel is already handling this issue.
      We are investigating it.

      • After printing some variable in my error_log, it looks like this happens with fields like “Likert Scale” (radio buttons) from the WPFORMS ADDON “Survey & Polls” with plugin “WPForms Multilingual” activated on PHP 8+.

        • Thanks Dimitri. This may not be related to our release, there is not mention to our glue plugin on the stack. However, there was a also WPForms release.
          Let’s continue in the ticket.

  5. Same for me… A new fatal error, still not sending a warning email. Again, I discovered it by chance making some testing. This means we lost all emails for a few days again. Please correct that asap.

    • We are sorry for the inconveniences @drissT, however this error should be solved already. Are you using WPForms Multilingual 0.3.1? If so, could you please share the error you are getting and open a chat in our forum so we can investigate it?

  6. Hi Andres,

    Thank you for your answer. Yes, I am using WPForms Multilingual version 0.3.1.
    The issue seems very similar to the one Dimitri is facing:
    – Only concerns the forms with radio button
    – PHP 8.2 (ea-php82)

    Once a form is sent, instead of redirecting to the ‘thank you page’, it displays the form with the tag {email} within an alert box.
    The data are stored in the DB but no mail is sent.
    Sure, I’ll open a new ticket.

    • Thank you for your help @drissT. The second report from Dimitri is related to WPForms Surveys and Polls extension, is it your case as well?

  7. Of course. No, I did not install those extensions. In the meantime, I opened a chat with one of your colleague fo WPML, he suggests as a workaround to downgrade the environment to PHP 7.4 or 8.0.
    I did the downgrade to 8.0 and it seems to be working.

    • I’m glad that the workaround helped. However it would be great if we can give it a closer look.
      If you are interested, don’t hesitate to open a new ticket and ping me, I’ll take it directly.
      You can also share the link here.

      Thank you very much for your help.
      Andrés