• Resolved Mario62rus

    (@mario62rus)


    Hello.
    The plugin v2.2.1 is installed on my website and in WordPress logs I see the PHP Parse error: syntax error, unexpected ‘?’ in /public_html/wp-content/object-cache.php on line 1242.
    The following code is written in this line:
    }, $tx->{$method}() ?? [] );
    How to fix this error?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    What PHP version are you on?

    Thread Starter Mario62rus

    (@mario62rus)

    7.4.25

    Plugin Author Till Krüss

    (@tillkruess)

    Are you sure you’re not running 5.6?

    Can you post your diagnostics from Settings > Redis > Diagnostics?

    This snippet fails on PHP 5.6, but works on PHP 7.4:

    <?php
    
    class Test123 {
      public function test() {
        return 'hello';
      }
    }
    
    $method = 'test';
    
    $tx = new Test123;
    
    var_dump($tx->{$method}() ?? []);
    Thread Starter Mario62rus

    (@mario62rus)

    Diagnostics from Settings > Redis > Diagnostics:

    Status: Подключено
    Client: PhpRedis (v5.0.2)
    Drop-in: Valid
    Disabled: No
    Ping: 1
    Errors: []
    PhpRedis: 5.0.2
    Relay: Not loaded
    Predis: Not loaded
    Credis: Not loaded
    PHP Version: 7.4.25
    Plugin Version: 2.2.1
    Redis Version: 6.2.4
    Multisite: No
    Metrics: Enabled
    Metrics recorded: 2038
    Filesystem: Working
    Global Prefix: "wp_"
    Blog Prefix: "wp_"
    Global Groups: [
        "blog-details",
        "blog-id-cache",
        "blog-lookup",
        "global-posts",
        "networks",
        "rss",
        "sites",
        "site-details",
        "site-lookup",
        "site-options",
        "site-transient",
        "users",
        "useremail",
        "userlogins",
        "usermeta",
        "user_meta",
        "userslugs",
        "redis-cache",
        "blog_meta"
    ]
    Ignored Groups: [
        "counts",
        "plugins",
        "themes"
    ]
    Unflushable Groups: []
    Groups Types: {
        "blog-details": "global",
        "blog-id-cache": "global",
        "blog-lookup": "global",
        "global-posts": "global",
        "networks": "global",
        "rss": "global",
        "sites": "global",
        "site-details": "global",
        "site-lookup": "global",
        "site-options": "global",
        "site-transient": "global",
        "users": "global",
        "useremail": "global",
        "userlogins": "global",
        "usermeta": "global",
        "user_meta": "global",
        "userslugs": "global",
        "redis-cache": "global",
        "counts": "ignored",
        "plugins": "ignored",
        "themes": "ignored",
        "blog_meta": "global"
    }
    Drop-ins: [
        "advanced-cache.php v by ",
        "Redis Object Cache Drop-In v2.2.1 by Till Krüss"
    ]
    • This reply was modified 2 years, 4 months ago by Mario62rus.
    Plugin Author Till Krüss

    (@tillkruess)

    Is one of your CLI processes running 5.6?

    How often are you seeing the Parse error?

    Thread Starter Mario62rus

    (@mario62rus)

    Is one of your CLI processes running 5.6?

    I find it difficult to answer. I run a PHP script on the hosting using the shell_exec command. I think that it is at such moments that a failure occurs.

    Plugin Author Till Krüss

    (@tillkruess)

    That would be the culprit then.

    echo shell_exec('php --version')

    Thread Starter Mario62rus

    (@mario62rus)

    You were right. The shell_exec() command runs under the old PHP version. To run this command under a new version of PHP, you need to do it like this:
    shell_exec( "/usr/local/bin/php7.4 path_to_script" );

    Thanks

    My site got the same error. Can you help me fix it?
    This error happens very often.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Syntax error’ is closed to new replies.