| CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Starting a new issue as the definitive place to point users who've run into this.
WP-CLI uses a custom version of WordPress's wp-settings.php file. Here's a narrative version of the backstory. Before WP-CLI can load wp-settings-cli.php, it needs to know all of the constants defined in wp-config.php (database connection details and so on).
In a typical WordPress install, wp-config.php has the following at the end of the file:
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
This is the code that loads WordPress. Because WP-CLI doesn't want WordPress to load yet when it's pulling the constants out of wp-config.php, it uses regex to strip the require_once(ABSPATH . 'wp-settings.php'); statement.
But, if the regex fails for whatever reason, WordPress gets loaded via the normal wp-settings.php statement when wp-config.php is evaluated, and WP-CLI can fail in a variety of cryptic ways.