• Resolved KZeni

    (@kzeni)


    I have a site that’s still on PHP 7.2 (with this plugin’s details currently saying it supports PHP 5.6 and newer), and it updated to Two-Factor 0.9.0 that was just released today to then find the entire site had a fatal server error.

    Thankfully, it seems to be a quick fix.

    I needed to edit two-factor/classtwo-factor-core.php to make 2 changes.

    Lines 1450-1455 had:

    		if ( ! $provider ) {
    			return new WP_Error(
    				'two_factor_provider_missing',
    				__( 'Cheatin’ uh?', 'two-factor' ),
    			);
    		}

    when that should instead be:

    		if ( ! $provider ) {
    			return new WP_Error(
    				'two_factor_provider_missing',
    				__( 'Cheatin’ uh?', 'two-factor' )
    			);
    		}

    Additionally, lines 1725-1728 had:

    		printf(
    			'<fieldset id="two-factor-options" %s>',
    			$show_2fa_options ? '' : 'disabled="disabled"',
    		);

    which should instead be:

    		printf(
    			'<fieldset id="two-factor-options" %s>',
    			$show_2fa_options ? '' : 'disabled="disabled"'
    		);

    The difference can be tough to spot as it’s really only the removal of the trailing comma when listing out parameters. While PHP can be more lenient with the trailing comma when using arrays, etc. there are some PHP versions around PHP 7.2 (and definitely all of 7.2.x) where the trailing comma when listing out parameters causes a syntax error resulting in a full-site fatal server error in this case (when that trailing comma isn’t even doing anything anyway other than potentially having it break for some PHP versions.)

    Hopefully, this is just a quick 0.9.1 release fix so fewer sites update to the potentially problematic 0.9.0 version, and one can just be mindful of and/or test for trailing commas like this before releasing future versions. Alternatively, 0.9.1 could be released as the last version that supports these older PHP versions (includes this quick fix) while then the next version release sets the PHP requirement to something above PHP 7.2 to avoid needing to worry about this.

    This has also been submitted as a GitHub Pull Request at: https://github.com/WordPress/two-factor/pull/604

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.