Support » Plugin: Material Design for Contact Form 7 » Latest version check breaks plugin

  • Resolved dakao

    (@dakao)



    Using versions:
    – WordPress: 4.9.6
    – Contact Form 7: 5.0.2
    – Material Design for Contact Form 7 (Premium): 1.7.6

    Receiving error:

    [07-Jun-2018 21:40:54 UTC] PHP Parse error: syntax error, unexpected '[' in /home/***/public_html/wp-content/plugins/material-design-for-contact-form-7-premium/public/cf7-material-design-public.php on line 422

    Relevant line is:

    $cf7v5_class = intval( WPCF7_VERSION[0] ) >= 5 ? 'cf7md-is-wpcf7v5 ' : '';

    Fix is to change line to:

    $cf7v5_class = version_compare( WPCF7_VERSION, '5.0.0', '>=') ? 'cf7md-is-wpcf7v5 ' : '';

    Thanks

    • This topic was modified 7 months, 2 weeks ago by  dakao. Reason: More accurate title
    • This topic was modified 7 months, 2 weeks ago by  dakao. Reason: Add versions used
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Contact Form 7 Addons

    (@contactform7addons)

    Hi @dakao,

    Thanks for the suggested fix, I didn’t know about the version_compare function and will update the code.

    I’m still not sure why the original version would break though, what PHP version are you using? Do you have any idea why it might not work?

    Thanks,
    Angus

    Plugin Contributor Contact Form 7 Addons

    (@contactform7addons)

    Hi @dakao,

    FYI I have updated both versions of the plugin (free and premium) with your suggested fix.

    Thanks again,
    Angus

    Hi Angus (@contactform7addons),

    We’re using the following for PHP:

    PHP 5.4.45 (cgi-fcgi) (built: Apr  1 2017 01:24:42)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

    I did some further testing and it looks like the method for indexing used isn’t supported until PHP 5.6.

    I have the following versions of PHP compiled locally:

    php-5.5.38  php-5.6.30  php-7.0.17  php-7.1.3
    
    $ find php-*/dist/bin -name php -exec {} -r "define( 'TEST_VERSION', '5.0.2'); echo 'PHP '.phpversion().' yields '.TEST_VERSION[0].PHP_EOL;" \;
    
    Parse error: syntax error, unexpected '[', expecting ',' or ';' in Command line code on line 1
    PHP 5.6.30 yields 5
    PHP 7.0.17 yields 5
    PHP 7.1.3 yields 5
    

    Thanks for getting that fixed! Much appreciated

    Plugin Contributor Contact Form 7 Addons

    (@contactform7addons)

    Thanks @dakao,

    I wondered why I couldn’t find any reference to this issue, it looks like it only affects PHP constants and not regular strings.

    https://stackoverflow.com/questions/3115595/php-constant-string-square-bracket-indexing

    Thanks again for your help,
    Angus

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Latest version check breaks plugin’ is closed to new replies.