• Resolved ssandison

    (@ssandison)


    Hopefully this is helpful. My site is breaking because your plugin is not compatible with versions of PHP lower than PHP 8.

    This is because of the following code:

    In includes/rest-api.php:

    public function create_feedback( WP_REST_Request $request ) {
    		$content_type = $request->get_header( 'Content-Type' );
    
    		if ( ! str_starts_with( $content_type, 'multipart/form-data' ) ) {
    			return new WP_Error( 'wpcf7_unsupported_media_type',
    				__( "The request payload format is not supported.", 'contact-form-7' ),
    				array( 'status' => 415 )
    			);
    		}

    To make this work with PHP 7.4 I had to update as follows:

    public function create_feedback( WP_REST_Request $request ) {
    		$content_type = $request->get_header( 'Content-Type' );
    
    		//if ( ! str_starts_with( $content_type, 'multipart/form-data' ) ) {
    		if (!substr($content_type, 0, strlen('multipart/form-data')) === 'multipart/form-data') {
    			return new WP_Error( 'wpcf7_unsupported_media_type',
    				__( "The request payload format is not supported.", 'contact-form-7' ),
    				array( 'status' => 415 )
    			);
    		}

    The current version of WordPress supports PHP 7.4 so you may want to update your plugin accordingly as I expect there will be lots of people experiencing this issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter ssandison

    (@ssandison)

    I’ve already patched the plugin now but looking at it more closely this is to do with the plugin being compatible with WP 5.9 onwards and this is a site where I haven’t updated it yet.

    WP 5.9 adds this function in for sites that are using PHP below version 8 so I guess its ok if you have 5.9 onwards.

    Your plugin minimum WordPress version is 5.9 so this error makes sense now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘500 errors on PHP 7.4’ is closed to new replies.