wp-cli: wp language core install fails on PHP8

Hello there!

Installing of languages fails when using wordpress and wp-cli with PHP8:

bash-5.1$ wp language core install de_DE_formal Fatal error: Declaration of WP_CLI\LanguagePackUpgrader::download_package($package, $check_signatures = false) must be compatible with WP_Upgrader::download_package($package, $check_signatures = false, $hook_extra = []) in phar:///usr/local/bin/wp/vendor/wp-cli/language-command/src/WP_CLI/LanguagePackUpgrader.php on line 51

System-Info: bash-5.1$ wp --info OS: Linux 5.9.16-200.fc33.x86_64 #1 SMP Mon Dec 21 14:08:22 UTC 2020 x86_64 Shell: PHP binary: /usr/local/bin/php PHP version: 8.0.1 php.ini used: WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /var/www/html WP-CLI packages dir: WP-CLI global config: WP-CLI project config: WP-CLI version: 2.4.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

@wojsmol The package that wp cli update --nightly downloads is broken, at least on php8. Downloading it manually and running it I get the dump below. I really hope a new version is released soon because there are numerous issues with 2.4.0. What happened to the 3-4 month release cadence?

PHP Warning:  require_once(phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8): Failed to open stream: phar error: "vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8" is not a file in phar "/home/dev/bin/wp" in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php on line 115

Warning: require_once(phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8): Failed to open stream: phar error: "vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8" is not a file in phar "/home/dev/bin/wp" in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php on line 115
PHP Fatal error:  Uncaught Error: Failed opening required 'phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8' (include_path='.:') in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php:115
Stack trace:
#0 phar:///home/dev/bin/wp/vendor/composer/autoload_real.php(71): require()
#1 phar:///home/dev/bin/wp/vendor/composer/autoload_real.php(61): composerRequire123e1944cad69e3ca35f2bec23f6dbf7()
#2 phar:///home/dev/bin/wp/vendor/autoload.php(7): ComposerAutoloaderInit123e1944cad69e3ca35f2bec23f6dbf7::getLoader()
#3 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/AutoloaderStep.php(49): require('...')
#4 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(75): WP_CLI\Bootstrap\AutoloaderStep->process()
#5 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#6 phar:///home/dev/bin/wp/php/boot-phar.php(11): include('...')
#7 /home/dev/bin/wp(4): include('...')
#8 {main}
  thrown in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php on line 115

Fatal error: Uncaught Error: Failed opening required 'phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8' (include_path='.:') in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php:115
Stack trace:
#0 phar:///home/dev/bin/wp/vendor/composer/autoload_real.php(71): require()
#1 phar:///home/dev/bin/wp/vendor/composer/autoload_real.php(61): composerRequire123e1944cad69e3ca35f2bec23f6dbf7()
#2 phar:///home/dev/bin/wp/vendor/autoload.php(7): ComposerAutoloaderInit123e1944cad69e3ca35f2bec23f6dbf7::getLoader()
#3 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/AutoloaderStep.php(49): require('...')
#4 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(75): WP_CLI\Bootstrap\AutoloaderStep->process()
#5 phar:///home/dev/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#6 phar:///home/dev/bin/wp/php/boot-phar.php(11): include('...')
#7 /home/dev/bin/wp(4): include('...')
#8 {main}
  thrown in phar:///home/dev/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php on line 115

wp-cli-bundle is restricting the vendor includes to just the php file extension and we have here a file named mb_convert_variables.php8.

I opened a PR. The following works if you want to get up and running with php8 quickly.

git clone --depth 1 --branch handle-php8-file-extension https://github.com/alexholt/wp-cli-bundle
cd wp-cli-bundle
composer install
php -dphar.readonly=0 utils/make-phar.php wp.phar
cp wp.phar /usr/bin/wp

Hi there, Using PHP 8.0 and 8.1, I still got this issue with wp-cli in the version downloaded from official repo (WP-CLI 2.6.0). Using the nightly version is working fine tho (what is the diff btw?).

I’m currently wrapping everything up around v2.5.0, as all upstream blockers have been resolved, so expect it to be published in the coming days.

I’m closing this issue, as this is fixed in the current state of the code. If you notice a similar issue with the current nightly or current master branch, please open a new issue.

Good question. @schlessera is there something we can do to help get 2.5 to stable?

@wojsmol Not sure if it’s “expected” by end users who follow official guidelines from here:

https://wp-cli.org/#installing

And then get an old-as-balls version of wp-cli installed? 😃

Do you know how we get our hands on up-to-date stable releases with a “scriptable” (i.e. does not change abritrarily) URL ?

This is related to php function declaratiON and was fixed long time ago in nightly version of WP-CLI - both for core and language commends. To update to latest nightly version please run wp cli update --nightly.