WP-CLI fails to update with WordPress 4.6 onwards

This may seem like it’s becoming something of a tradition, but if you’re a WP-CLI (WordPress Command Line Interface) user and you’ve recently updated your website to WordPress 4.6, you may notice that plugin updates no longer work correctly.

You’ll probably get an error like this:

PHP Fatal error:  Call to undefined function apply_filters() in /Library/WebServer/Sites/example.dev/wp-includes/load.php on line 317

Of course, the actual file path that appears in the error message will depend on your web server configuration, but the “Call to undefined function” message and the reference to wp-includes/load.php will probably be the same.

This happens because the upgraded WordPress software is no longer compatible with your version of WP-CLI. Fortunately, updating WP-CLI is all you need to do.

In order to update your WP-CLI software,you just need to issue three Terminal/Shell commands, according to WP-CLI’s installation guide:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

That’s it!

So why does every major WordPress update seem to break WP-CLI? It’s because WP-CLI has had to use a forked version of WordPress’ bootstrap file (a file called wp-settings-cli.php is used instead of wp-settings.php), which means that it doesn’t get updated along with the core WordPress software. When the the core wp-settings.php file changes with a new WordPress release, the wp-settings-cli.php can become incompatible. However, thanks to a little coordination with the folks who work on the WordPress project, this should no longer be an issue as of WP-CLI 0.24.0 and WordPress 4.6; WP-CLI is now able to rely on the core wp-settings.php file (no more forks!). Hopefully this means that I’ll never have to write a post like this again!


Leave a comment