Skip to content

Commit 420118c

Browse files
committed
Handle extra-php input
1 parent f2f5fc0 commit 420118c

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

src/Config_Command.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ public function create( $_, $assoc_args ) {
239239
'config-file' => rtrim( ABSPATH, '/\\' ) . '/wp-config.php',
240240
];
241241

242+
if ( Utils\wp_version_compare( '4.0', '<' ) ) {
243+
$defaults['add-wplang'] = true;
244+
} else {
245+
$defaults['add-wplang'] = false;
246+
}
247+
242248
if ( ! Utils\get_flag_value( $assoc_args, 'skip-salts' ) ) {
243249
try {
244250
$defaults['keys-and-salts'] = true;
@@ -259,19 +265,14 @@ public function create( $_, $assoc_args ) {
259265
}
260266
}
261267

262-
if ( Utils\wp_version_compare( '4.0', '<' ) ) {
263-
$defaults['add-wplang'] = true;
264-
} else {
265-
$defaults['add-wplang'] = false;
266-
}
267-
268268
$path = $defaults['config-file'];
269269
if ( ! empty( $assoc_args['config-file'] ) ) {
270270
$path = $assoc_args['config-file'];
271271
}
272272

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

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

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

290-
// 'extra-php' from STDIN is retrieved after escaping to avoid breaking
291-
// the PHP code.
292-
if ( Utils\get_flag_value( $assoc_args, 'extra-php' ) === true ) {
293-
$assoc_args['extra-php'] = file_get_contents( 'php://stdin' );
294-
}
295-
296291
$options = [
297292
'raw' => false,
298293
'add' => true,

0 commit comments

Comments
 (0)