diff --git a/wp-cli.php b/wp-cli.php index 33be2818bf..23357d18a1 100644 --- a/wp-cli.php +++ b/wp-cli.php @@ -45,6 +45,16 @@ function maybe_toggle_is_ssl() { } } +/** + * Disable the SAVEQUERIES for all the WP CLI interactions, unless already defined. + * SAVEQUERIES tracks is quite expensive if turned on and can lead to OOM and performance issues, it should be enabled only when needed. + */ +function maybe_disable_savequeries() { + if ( ! defined( 'SAVEQUERIES' ) ) { + define( 'SAVEQUERIES', false ); + } +} + /** * Disable `display_errors` for all wp-cli interactions on production servers. * @@ -71,6 +81,8 @@ function disable_display_errors() { init_is_ssl_toggle(); + maybe_disable_savequeries(); + foreach ( glob( __DIR__ . '/wp-cli/*.php' ) as $command ) { require $command; }