Skip to content

Commit

Permalink
Disable SAVEQUERIES in WP CLI commands (#4981)
Browse files Browse the repository at this point in the history
* disable SAVEQUERIES for all the WP CLI commands, unless already defined.

* fix linting (missing space)
  • Loading branch information
andrea-sdl authored Oct 27, 2023
1 parent be168c7 commit eead23c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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;
}
Expand Down

0 comments on commit eead23c

Please sign in to comment.