Skip to content

Commit 7f022d1

Browse files
authored
Merge pull request #188 from pwtyler/double-errors-4944
Suppress output of eval(get_wp_config_code) preventing errors printing twice
2 parents effb789 + cce428a commit 7f022d1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Config_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,12 @@ private static function get_wp_config_vars( $wp_config_path = '' ) {
552552
$wp_cli_original_defined_vars = get_defined_vars();
553553
$wp_cli_original_includes = get_included_files();
554554

555+
// Output buffering prevents warnings or notices while parsing wp-config
556+
// from printing twice. See https://github.com/wp-cli/wp-cli/issues/4944
557+
ob_start();
555558
// phpcs:ignore Squiz.PHP.Eval.Discouraged -- Don't have another way.
556559
eval( WP_CLI::get_runner()->get_wp_config_code( $wp_config_path ) );
560+
ob_end_clean();
557561

558562
$wp_config_vars = self::get_wp_config_diff( get_defined_vars(), $wp_cli_original_defined_vars, 'variable', [ 'wp_cli_original_defined_vars' ] );
559563
$wp_config_constants = self::get_wp_config_diff( get_defined_constants(), $wp_cli_original_defined_constants, 'constant' );

0 commit comments

Comments
 (0)