• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

error wpcli wp-toolkit

fferraro87

Basic Pleskian
Hi,

i'm trying to use wp cli in order to update wp core and themes so i do that command :

Code:
plesk ext wp-toolkit --wp-cli -instance-id 13 -- theme update --all

but i've that error :

Code:
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/php/polyfills/WP_CLI/UpgraderSkin.php on line 34

How can i fix this? there is a way to update wp toolkit?
i've installed Plesk Version 18.0.21 Update #4 on a CentOS Linux 7.7.1908

Thanks
 
I believe the wp-cli package only supports PHP 5.4 and up, so the version of wp-cli in wp-toolkit was modified by adding the UpgraderSkin “polyfill” for PHP 5.3 compatibility. That’s even what the comment on the polyfill class states: “Backport for compatibility with wordpress 5.3.”

Besides this comment, the only other difference between the polyfill and the class that is actually part of the wp-cli package at version 1.4 is how the feedback method handles additional arguments:

8,9d7
< * Backport for compatibility with wordpress 5.3
< *
34c32
< public function feedback( $string, ...$args ) {
---
> public function feedback( $string ) {
44a43,44
> $args = func_get_args();
> $args = array_splice( $args, 1 );


Ironically, the splat operator was only introduced in 5.6, which means that this polyfill is no longer compatible with 5.3, which is seemingly the only reason the polyfill was created. Further, the change appears to be unnecessary, because it effectively it does the same thing only with a newer feature. My guess is that this change was introduced around December 6.

The toolkit is invoked with a php7 binary, but my assumption is that it invokes certain scripts with a binary that is the same version any given site is running. Hence, toolkit will encounter this problem with any site running on php 5.5 or older.

My assumption is that wp-toolkit looks for a polyfill class and, if one exists, uses it in place of the matching vendor class. So because the polyfill appears to be unnecessary, I just renamed

/usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/php/polyfills/WP_CLI/UpgraderSkin.php

to

/usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/php/polyfills/WP_CLI/UpgraderSkin.php.bak

and now it appears that the actual vendor file is used and the polyfill is ignored, as the error has disappeared. Hopefully this is fixed in the next wp-toolkit update.

Now of course all these sites should be updated to use php 7 or newer — I get that, but in my case it’s just not going to happen.
 
Newer versions of WordPress require newer php versions. This polyfill is required for compatibility with the new version of WordPress. There is no way back, this is caused by a change in the method signatures in the wordpress itself:

Code Modernisation: Introduce the spread operator in `wp-admin/includ… · WordPress/WordPress@340b7b5

If the version of your WordPress is less than 5.3, you can delete this polyfill (but when updating wp-toolkit extension it will appear again)
Or use php version 5.6 (or higher) on this domain, which is also required by the new version of WordPress.
 
Back
Top