Skip to content

Commit

Permalink
Merge pull request #118 from wp-cli/fix/gracefully-handle-missing-db-…
Browse files Browse the repository at this point in the history
…credentials

Handle missing DB credentials gracefully
  • Loading branch information
schlessera authored May 5, 2021
2 parents 6b6f201 + 7ec79e7 commit a7bc939
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,17 @@ public function __construct() {
$this->variables['MYSQL_HOST'] = getenv( 'MYSQL_HOST' );
}

self::$db_settings['dbuser'] = $this->variables['DB_USER'];
self::$db_settings['dbpass'] = $this->variables['DB_PASSWORD'];
self::$db_settings['dbhost'] = $this->variables['DB_HOST'];
self::$db_settings['dbuser'] = array_key_exists( 'DB_USER', $this->variables )
? $this->variables['DB_USER']
: 'wp_cli_test';

self::$db_settings['dbpass'] = array_key_exists( 'DB_PASSWORD', $this->variables )
? $this->variables['DB_PASSWORD']
: 'password1';

self::$db_settings['dbhost'] = array_key_exists( 'DB_HOST', $this->variables )
? $this->variables['DB_HOST']
: 'localhost';

$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );

Expand Down

0 comments on commit a7bc939

Please sign in to comment.