Viewing 1 post (of 1 total)
  • Author
    Posts
  • #828702

    Dear all,

    Don’t worry, nothing harmfull up to now, but :

    In /wp-content/themes/enfold/config-woocommerce/config.php

    Lines 154 and 157 generate warnings since PHP 7.1 when using wp-cli command “wp theme status” (not when accessing from the web). Anyway, since PHP 7.1, the code under the comment “fallback, if options have not been saved”, does not behave as with previous PHP versions.

    $options = avia_get_option();
    		
    //	Fallback, if options have not been saved
    if( empty( $options['product_gallery'] ) )
    {
    	$options['product_gallery'] = '';
    }
    
    if( 'wc_30_gallery' == $options['product_gallery'] )
    {
    	...

    $options may be an empty string, and is an empty string with said wp-cli command, and in PHP 7.1, an empty string is not anymore transformed into an array when trying to assign something to an offset, and you cannot assign an empty string to a string offset :
    $empty_string = '';
    $empty_string[0] = ''; // <= $empty_string is not transformed to array, it stays a string and as such you cannot assign ” to this offset

    We get :

    Warning: Illegal string offset ‘product_gallery’ in …config-woocommerce/config.php on line 154
    Warning: Cannot assign an empty string to a string offset in …config-woocommerce/config.php on line 154
    Warning: Illegal string offset ‘product_gallery’ in config-woocommerce/config.php on line 157

    References :
    https://bugs.php.net/bug.php?id=71572
    https://github.com/php/php-src/pull/1761
    https://github.com/php/php-src/commit/be607e724c69c92f8cda72a45a13a26e7c439aec

    May be solution :

    if ( empty( $options['product_gallery'] ) )
    {
    	return;
    }

    Best regards

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.