Skip to content

Commit

Permalink
Handle extra-php input
Browse files Browse the repository at this point in the history
  • Loading branch information
UmeshSingla committed May 18, 2024
1 parent f2f5fc0 commit 420118c
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/Config_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ public function create( $_, $assoc_args ) {
'config-file' => rtrim( ABSPATH, '/\\' ) . '/wp-config.php',
];

if ( Utils\wp_version_compare( '4.0', '<' ) ) {
$defaults['add-wplang'] = true;
} else {
$defaults['add-wplang'] = false;
}

if ( ! Utils\get_flag_value( $assoc_args, 'skip-salts' ) ) {
try {
$defaults['keys-and-salts'] = true;
Expand All @@ -259,19 +265,14 @@ public function create( $_, $assoc_args ) {
}
}

if ( Utils\wp_version_compare( '4.0', '<' ) ) {
$defaults['add-wplang'] = true;
} else {
$defaults['add-wplang'] = false;
}

$path = $defaults['config-file'];
if ( ! empty( $assoc_args['config-file'] ) ) {
$path = $assoc_args['config-file'];
}

if ( ! empty( $assoc_args['extra-php'] ) ) {
$defaults['extra-php'] = $this->escape_config_value( 'extra-php', $assoc_args['extra-php'] );
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
// 'extra-php' from STDIN is retrieved.
$defaults['extra-php'] = file_get_contents( 'php://stdin' );
}

$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
Expand All @@ -287,12 +288,6 @@ public function create( $_, $assoc_args ) {

$assoc_args = array_merge( $defaults, $assoc_args );

// 'extra-php' from STDIN is retrieved after escaping to avoid breaking
// the PHP code.
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
$assoc_args['extra-php'] = file_get_contents( 'php://stdin' );
}

$options = [
'raw' => false,
'add' => true,
Expand Down

0 comments on commit 420118c

Please sign in to comment.