Support » Plugin: WordPress Affiliates Plugin — SliceWP » Syntax error T_PAAMAYIM_NEKUDOTAYIM

  • Resolved useStrict

    (@usestrict)


    Hi, I’m seeing the following error when I activate the plugin via wp-cli:

    Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /path/to/wp-content/plugins/slicewp/includes/base/abstracts/abstract-class-migration.php on line 125

    I saw this in version 1.0.44 and am seeing it in version 1.0.46 as well. PHP 7.4.22.

    Please assist.

    Cheers,
    Vinny

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter useStrict

    (@usestrict)

    I later noticed that the plugin was actually inactive, although the client swears that it was active even yesterday.

    Anyway, I replaced that and other instances of the error with call_user_func() and was able to activate the plugin.

    Please fix this for the next version as I’d like to update to it asap.

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @usestrict,

    Can you please share the exact command you ran and also the full text of the error?

    Also, I see you’ve had the error appear in multiple instances. If you can share the entire error log that would help.

    Thank you and best wishes,
    Mihai

    Thread Starter useStrict

    (@usestrict)

    Hi Mihai,

    I got the error while trying to update the plugin via wp-cli, then when trying to activate it.

    All errors were in that same file:

    includes/base/abstracts/abstract-class-migration.php

    The problem was that the code used :: with a variable. I ran into that years ago with one of my first plugins. The fix was to use call_user_func() instead. I just tried to replicate the issue on a dev server (different ISP) but couldn’t. I’m wondering if wp-cli in the affected server was using a PHP version that was too old, and not the one I got when running php -v.

    Anyway, the fixes were as follows:

    Original:
    125 return in_array( $this->id, array_keys( slicewp()->services['migration_manager']::get_ran_migrations() ) );

    New:
    125 return in_array( $this->id, array_keys( call_user_func( [slicewp()->services['migration_manager'], 'get_ran_migrations'] ) ) );

    Original:
    136 slicewp()->services['migration_manager']::update( $this->id );

    New:
    136 call_user_func( [slicewp()->services['migration_manager'], 'update'], $this->id );

    Original:
    159 slicewp()->services['migration_manager']::update( $this->id, 'dismissed' );

    New:
    159 call_user_func([slicewp()->services['migration_manager'],'update'], $this->id, 'dismissed' );

    Cheers,
    Vinny

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @usestrict,

    Quite weird. Haven’t seen the error in years.

    Nevertheless, I’ll look into it and test the refactored code you’ve shared. If it’s all good, an update will be available sometime next week.

    Thank you for sharing the code!

    Also, if there’s anything regarding SliceWP, please let me know.

    Best wishes,
    Mihai

    Thread Starter useStrict

    (@usestrict)

    Hi Mihai,

    My suspicions were right. The host that threw the error has wp-cli running on PHP 5.6, even though php -v shows 7.4. PHP 5.6 does not support calling static functions as $foo::do_something().

    Cheers,
    Vinny

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @usestrict,

    The code you shared has been added to SliceWP. Please try it out and let me know how it goes.

    Please note however that this solution is only temporary. In a later version we will be dropping support for PHP versions older than 7 and we will revert to the code that was previously in place. We currently don’t have a time frame for when this will happen however.

    Best wishes,
    Mihai

    Thread Starter useStrict

    (@usestrict)

    Thanks, Mihai.

    We also plan to be moving away from the host that has php 5.6 running for wp-cli.

    Cheers,
    Vinny

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