Skip to content

Commit

Permalink
Merge pull request #188 from pwtyler/double-errors-4944
Browse files Browse the repository at this point in the history
Suppress output of eval(get_wp_config_code) preventing errors printing twice
  • Loading branch information
schlessera authored Nov 1, 2024
2 parents effb789 + cce428a commit 7f022d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Config_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 7f022d1

Please sign in to comment.