From cce428a724356422f9e9ded887076dcfc89dcc36 Mon Sep 17 00:00:00 2001 From: Phil Tyler Date: Tue, 17 Sep 2024 12:02:52 -0700 Subject: [PATCH] Suppress output of eval(get_wp_config_code) to prevent errors printing twice --- src/Config_Command.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Config_Command.php b/src/Config_Command.php index 35e39116..f1daf713 100644 --- a/src/Config_Command.php +++ b/src/Config_Command.php @@ -552,8 +552,12 @@ private static function get_wp_config_vars( $wp_config_path = '' ) { $wp_cli_original_defined_vars = get_defined_vars(); $wp_cli_original_includes = get_included_files(); + // Output buffering prevents warnings or notices while parsing wp-config + // from printing twice. See https://github.com/wp-cli/wp-cli/issues/4944 + ob_start(); // phpcs:ignore Squiz.PHP.Eval.Discouraged -- Don't have another way. eval( WP_CLI::get_runner()->get_wp_config_code( $wp_config_path ) ); + ob_end_clean(); $wp_config_vars = self::get_wp_config_diff( get_defined_vars(), $wp_cli_original_defined_vars, 'variable', [ 'wp_cli_original_defined_vars' ] ); $wp_config_constants = self::get_wp_config_diff( get_defined_constants(), $wp_cli_original_defined_constants, 'constant' );