Skip to content

Commit 96062f2

Browse files
authored
Merge pull request #212 from wp-cli/copilot/fix-wp-cli-config-detection
2 parents e7f0c34 + 2f8bbd3 commit 96062f2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

features/config-create.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,21 @@ Feature: Create a wp-config file
275275
my\\password
276276
"""
277277
278+
Scenario: wp-config.php in parent folder should not prevent config create in subfolder
279+
Given an empty directory
280+
And a wp-config.php file:
281+
"""
282+
<?php
283+
echo "some broken or custom wp-config.php file";
284+
"""
285+
286+
When I run `wp core download --path=subdir`
287+
Then the return code should be 0
288+
289+
When I run `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --path=subdir`
290+
Then the return code should be 0
291+
And the subdir/wp-config.php file should exist
292+
278293
@require-mysql @require-mysql-5.7
279294
Scenario: Configure with required SSL connection
280295
Given an empty directory

src/Config_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function create( $_, $assoc_args ) {
202202
if ( ! Utils\get_flag_value( $assoc_args, 'force' ) ) {
203203
if ( isset( $assoc_args['config-file'] ) && file_exists( $assoc_args['config-file'] ) ) {
204204
$this->config_file_already_exist_error( basename( $assoc_args['config-file'] ) );
205-
} elseif ( ! isset( $assoc_args['config-file'] ) && Utils\locate_wp_config() ) {
205+
} elseif ( ! isset( $assoc_args['config-file'] ) && file_exists( rtrim( ABSPATH, '/\\' ) . '/wp-config.php' ) ) {
206206
$this->config_file_already_exist_error( 'wp-config.php' );
207207
}
208208
}

0 commit comments

Comments
 (0)