wp-cli errors, plugins need newer PHP?

Is your wp-cli using an old version of PHP, older than WordPress runs in? If you get errors in wp-cli, for example with wp plugin list, about a plugin needing a newer version of PHP, this is how to fix it (temporarily).

Sometimes website hosting companies upgrade your WordPress PHP version, but fall behind updating the PHP version for your SSH terminal connection to the site.

The long-term solution is get your hosting company to update the ssh version of PHP.

Boo, hiss to those negligent website hosting companies. They should always keep PHP versions updated, at least above the minimum recommended version for WordPress. In June 2023, that minimum is PHP 7.4.
It is currently very common now for sites to be running on PHP 8.1 or newer.
Even though the recommended minimum version of PHP for WordPress is PHP 7.4, I suggest don’t run WordPress anymore on PHP older than PHP 8.1, and it’s better to be using PHP 8.2 or newer.

Plugin authors are starting to use the good enhancements in newer versions of PHP, setting their minimum PHP version to 7.4. Good for them!

This error is not the plugin author’s fault. It is the hosting company’s fault, for still having an old version of PHP in use.

Here is the full error message for one plugin, but understand that each plugin will have a different message. The important part is this: dependencies require a PHP version ">= 7____" whatever the version number is.

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.33-1+0~20211119.91+debian9~1.gbp618351. in /_____/wp-content/plugins/woo-store-vacation/vendor/composer/platform_check.php on line 24

That site’s SSH terminal is running PHP 7.3.__ (even though WordPress on that site is using PHP 8.1), while the plugin requires at least PHP 7.4.

Solution (the hard way):

Change the wp-cli command to tell it to skip running the plugins that require a newer PHP. This is harder because you have to type so many characters for so many commands.

For example, change wp plugin status to

wp plugin status --skip-plugins=ti-woocommerce-wishlist,woo-store-vacation

That “skip plugins” is a comma-separated list of the folder names of the plugins that require a newer version of PHP than your hosting company provides for your SSH terminal.

Remember, if WordPress itself is being run in too old a PHP version, this won’t fix it. Have your hosting company run WordPress in a newer version of PHP, minimum version 8.1. If they can’t do that, eww, move to a better hosting company!

How do you get a list of the plugins that need to be excluded? It’s right there in that error message. See “wp-content/plugins/woo-store-vacation/” in the error?

So in this case, –skip-plugins=woo-store-vacation

If you run wp plugin status again, you may see another plugin that has the same issue. Next time I ran that command, I saw “wp-content/plugins/ti-woocommerce-wishlist/” so, the new command includes --skip-plugins=ti-woocommerce-wishlist,woo-store-vacation .

Everything from “/plugins/” to the next “/”, and separate each of them with a comma and no spaces. The order of the plugins doesn’t matter.

Which wp-cli commands need this?

Many of them. Most of the commands that I use every time I am updating plugins and checking every plugin is okay and every administrative user is okay.

What is the Easy Way?

Instead of modifying each wp-cli command, tell wp-cli to always use the settings you need.

You can set global settings for wp-cli in a wp-cli.yml file in the WordPress root folder.

The documentation for this is in Config – WP-CLI – WordPress.org .

The hosts I use happen to all have nano as the text editor. Ask your hosting company what text editor to use.

Navigate to your WordPress root folder (the folder with wp-admin/ and wp-content/ ). Edit wp-cli.yml (you are likely making a new file, so it is empty, unless you created one before).

nano wp-cli.yml

Add a line like this, adjusting it to exclude your set of plugins:


skip-plugins: ti-woocommerce-wishlist,woo-store-vacation

Save that file, and you’re done.

Now, simple wp-cli commands such as wp plugin list should work normally.


Posted

in

by

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.