• Resolved joinso

    (@joinso)


    Hi!

    We are migrating our site from PHP 7 to PHP 8.

    Contact Form 7 is working well in PHP 7, but not in PHP 8.

    The working site is:
    https://www.tabiquepluvial.es/ca/contacte/
    The new site is working under this IP: 18.198.155.123
    So to test, you need to add this lines to your hosts file.
    18.198.155.123 https://www.tabiquepluvial.es
    18.198.155.123 tabiquepluvial.es

    After submitting the form, you will get the typical WordPress error page.
    and in logs:
    [14-Sep-2022 05:35:07 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_result() on null in /DOCUMENT_ROOT/wp-content/plugins/contact-form-7/includes/contact-form.php:1054
    Stack trace:
    #0 /DOCUMENT_ROOT/wp-content/plugins/contact-form-7/includes/controller.php(25): WPCF7_ContactForm->submit()
    #1 /var/www/tabiquepluvial/wp-includes/class-wp-hook.php(305): wpcf7_control_init()
    #2 /var/www/tabiquepluvial/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
    #3 /var/www/tabiquepluvial/wp-includes/plugin.php(524): WP_Hook->do_action()
    #4 /var/www/tabiquepluvial/wp-includes/class-wp.php(398): do_action_ref_array()
    #5 /var/www/tabiquepluvial/wp-includes/class-wp.php(770): WP->parse_request()
    #6 /var/www/tabiquepluvial/wp-includes/functions.php(1330): WP->main()
    #7 /var/www/tabiquepluvial/wp-blog-header.php(16): wp()
    #8 /var/www/tabiquepluvial/index.php(17): require(‘…’)
    #9 {main}
    thrown in /DOCUMENT_ROOT/wp-content/plugins/contact-form-7/includes/contact-form.php on line 1054

    Details old site:
    Contact Form 7 version: 5.6.3
    PHP 7.2.34
    Details new site:
    Contact Form 7 version: 5.6.3
    PHP 8.1

    Any idea?

    Regards,
    Jordi
    JOINSO

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter joinso

    (@joinso)

    Solved: just increase php memory limit from 128MB to 512MB.

    • This reply was modified 2 years, 2 months ago by joinso.

    I also have the same problem

    File: wp-content/plugins/contact-form-7/includes/contact-form.php
    1054: 		$result += $submission->get_result();

    I try print_r line 1504 it goes through 2 times, the first time it works properly, the second time the error appears.
    A temporary fix, I don’t know the exact fix yet, but you have to fix the plugin.
    Add this line of code:

    global $wpcf7_control_init_inited;
    if ($wpcf7_control_init_inited) {
     return;
    }
    $wpcf7_control_init_inited=1;

    In the function wpcf7_control_init at the file wp-content/plugins/contact-form-7/includes/controller.php

    The completed code will look like below, the error will be fixed:

    File: wp-content/plugins/contact-form-7/includes/controller.php
    13: /**
    14:  * Handles a submission in non-Ajax mode.
    15:  */
    16: function wpcf7_control_init() {
    17: 	global $wpcf7_control_init_inited;
    18: 	if ($wpcf7_control_init_inited) {
    19: 	return;
    20: 	}
    21: 	$wpcf7_control_init_inited=1;
    22: 
    23: 	if ( WPCF7_Submission::is_restful() ) {
    24: 		return;
    25: 	}
    26: 
    27: 	if ( isset( $_POST['_wpcf7'] ) ) {
    28: 		$contact_form = wpcf7_contact_form( (int) $_POST['_wpcf7'] );
    29: 
    30: 		if ( $contact_form ) {
    31: 			$contact_form->submit();
    32: 		}
    33: 	}
    34: }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Fatal error: Uncaught Error: Call to a member function get_result() on null’ is closed to new replies.