After upgrading an old WordPress site’s Ubuntu version from 18.04 to 20.04 and changing PHP from 7.4 to 8.0 we found that the Cron jobs weren’t running.

When we looked in in /var/log/syslog we found some errors about wp-cli when the job was trying to run.

We could reproduce the error with a wp-info like this:

:~# wp --info
PHP Fatal error:  Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in phar:///usr/bin/wp/php/WP_CLI/DocParser.php:75
Stack trace:
#0 phar:///usr/bin/wp/php/WP_CLI/DocParser.php(75): implode()
#1 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CompositeCommand.php(32): WP_CLI\DocParser->get_longdesc()
#2 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(111): WP_CLI\Dispatcher\CompositeCommand->__construct()
#3 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(43): WP_CLI\Dispatcher\CommandFactory::create_composite_command()
#4 phar:///usr/bin/wp/php/class-wp-cli.php(480): WP_CLI\Dispatcher\CommandFactory::create()
#5 phar:///usr/bin/wp/php/commands/cli.php(3): WP_CLI::add_command()
#6 phar:///usr/bin/wp/php/WP_CLI/Bootstrap/RegisterFrameworkCommands.php(32): include_once('...')
#7 phar:///usr/bin/wp/php/bootstrap.php(75): WP_CLI\Bootstrap\RegisterFrameworkCommands->process()
#8 phar:///usr/bin/wp/php/wp-cli.php(23): WP_CLI\bootstrap()
#9 phar:///usr/bin/wp/php/boot-phar.php(8): include('...')
#10 /usr/bin/wp(4): include('...')
#11 {main}
  thrown in phar:///usr/bin/wp/php/WP_CLI/DocParser.php on line 75 

So it looked like the wp-cli wasn’t working.

This is a change with PHP 8 that broke older versions of wp-cli.

We tried to re-install it using the instructions here:

curl -O
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

But when we did this we still got the error message.

For us the solution was that in /usr/bin there was another version of wp that was six years old! And this was the wp that was being referenced. When we did the above but moved the wp file to /usr/bin/wp instead of local then everything worked as normal.

Last modified: July 18, 2023



Write a Reply or Comment

Your email address will not be published.