From 16e98dcbb6da20b90a4e1f2254efaf15e5fc1bad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:13:20 +0000 Subject: [PATCH 1/5] Initial plan From 50bdb42791d85cf7a277db48f9123ed8ba8db039 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:25:03 +0000 Subject: [PATCH 2/5] Show literal true/false for boolean values in wp config get and wp config list Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/config-get-field.feature | 42 ++++++++++++++++++++ features/config-list.feature | 65 +++++++++++++++++++++++++++++-- src/Config_Command.php | 19 +++++++++ 3 files changed, 123 insertions(+), 3 deletions(-) diff --git a/features/config-get-field.feature b/features/config-get-field.feature index 27309cad..fea49a2b 100644 --- a/features/config-get-field.feature +++ b/features/config-get-field.feature @@ -293,3 +293,45 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp --- - wp_cli_test """ + + Scenario: Get a boolean true constant from wp-config.php shows literal "true" + Given a WP install + And a wp-config.php file: + """ + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_LOG', false ); + require_once( ABSPATH . 'wp-settings.php' ); + """ + + When I run `wp config get WP_DEBUG` + Then STDOUT should be: + """ + true + """ + + When I run `wp config get WP_DEBUG_LOG` + Then STDOUT should be: + """ + false + """ + + Scenario: Get a boolean constant preserves native type for json and yaml formats + Given a WP install + And a wp-config.php file: + """ + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_LOG', false ); + require_once( ABSPATH . 'wp-settings.php' ); + """ + + When I run `wp config get WP_DEBUG --format=json` + Then STDOUT should be: + """ + true + """ + + When I run `wp config get WP_DEBUG_LOG --format=json` + Then STDOUT should be: + """ + false + """ diff --git a/features/config-list.feature b/features/config-list.feature index cdc669c8..8f6097ec 100644 --- a/features/config-list.feature +++ b/features/config-list.feature @@ -412,11 +412,70 @@ Feature: List the values of a wp-config.php file SECURE_AUTH_SALT='VNH|C>w-z?*dtP4ofy!v%RumM.}ug]mx7$QZW|C-R4T`d-~x|xvL{Xc_5C89K(,^' LOGGED_IN_SALT='Iwtez|Q`M l7lup; x&ml8^C|Lk&X[3/-l!$`P3GM$7:WI&X$Hn)unjZ9u~g4m[c' NONCE_SALT='QxcY|80 $f_dRkn*Liu|Ak*aas41g(q5X_h+m8Z$)tf6#TZ+Q,D#%n]g -{=mj1)' - WP_ALLOW_MULTISITE=1 - MULTISITE=1 - SUBDOMAIN_INSTALL='' + WP_ALLOW_MULTISITE=true + MULTISITE=true + SUBDOMAIN_INSTALL=false DOMAIN_CURRENT_SITE='example.com' PATH_CURRENT_SITE='/' SITE_ID_CURRENT_SITE=1 BLOG_ID_CURRENT_SITE=1 """ + + Scenario: List boolean constants shows literal "true" and "false" in table format + Given a WP install + And a wp-config.php file: + """ + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_LOG', true ); + define( 'WP_DEBUG_DISPLAY', false ); + require_once( ABSPATH . 'wp-settings.php' ); + """ + + When I run `wp config list --fields=name,value,type --format=table` + Then STDOUT should be a table containing rows: + | name | value | type | + | WP_DEBUG | true | constant | + | WP_DEBUG_LOG | true | constant | + | WP_DEBUG_DISPLAY | false | constant | + + Scenario: List boolean constants preserves native boolean type for json format + Given a WP install + And a wp-config.php file: + """ + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_DISPLAY', false ); + require_once( ABSPATH . 'wp-settings.php' ); + """ + + When I run `wp config list WP_DEBUG --strict --format=json` + Then STDOUT should contain: + """ + {"name":"WP_DEBUG","value":true,"type":"constant"} + """ + + When I run `wp config list WP_DEBUG_DISPLAY --strict --format=json` + Then STDOUT should contain: + """ + {"name":"WP_DEBUG_DISPLAY","value":false,"type":"constant"} + """ + + Scenario: List boolean constants shows literal "true" and "false" in dotenv format + Given a WP install + And a wp-config.php file: + """ + define( 'WP_DEBUG', true ); + define( 'WP_DEBUG_DISPLAY', false ); + require_once( ABSPATH . 'wp-settings.php' ); + """ + + When I run `wp config list WP_DEBUG --strict --format=dotenv` + Then STDOUT should be: + """ + WP_DEBUG=true + """ + + When I run `wp config list WP_DEBUG_DISPLAY --strict --format=dotenv` + Then STDOUT should be: + """ + WP_DEBUG_DISPLAY=false + """ diff --git a/src/Config_Command.php b/src/Config_Command.php index ffd72851..378fff13 100644 --- a/src/Config_Command.php +++ b/src/Config_Command.php @@ -467,6 +467,14 @@ public function list_( $args, $assoc_args ) { return array_walk( $values, array( $this, 'print_dotenv' ) ); } + if ( ! in_array( $assoc_args['format'], [ 'json', 'yaml' ], true ) ) { + foreach ( $values as $index => $value ) { + if ( is_bool( $value['value'] ) ) { + $values[ $index ]['value'] = $value['value'] ? 'true' : 'false'; + } + } + } + Utils\format_items( $assoc_args['format'], $values, $assoc_args['fields'] ); } @@ -514,6 +522,12 @@ public function list_( $args, $assoc_args ) { */ public function get( $args, $assoc_args ) { $value = $this->get_value( $assoc_args, $args ); + if ( is_bool( $value ) ) { + $format = Utils\get_flag_value( $assoc_args, 'format' ); + if ( ! in_array( $format, [ 'json', 'yaml' ], true ) ) { + $value = $value ? 'true' : 'false'; + } + } WP_CLI::print_value( $value, $assoc_args ); } @@ -1451,6 +1465,11 @@ private function print_dotenv( array $value ) { $name = strtoupper( $value['name'] ); $variable_value = isset( $value['value'] ) ? $value['value'] : ''; + if ( is_bool( $variable_value ) ) { + WP_CLI::line( "{$name}=" . ( $variable_value ? 'true' : 'false' ) ); + return; + } + $variable_value = str_replace( "'", "\'", $variable_value ); if ( ! is_numeric( $variable_value ) ) { From 683dd1a13b2eed0e344bbf5b66f25ce669674193 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 12 Mar 2026 17:47:24 +0100 Subject: [PATCH 3/5] Update features/config-get-field.feature Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- features/config-get-field.feature | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/config-get-field.feature b/features/config-get-field.feature index fea49a2b..394ce4e9 100644 --- a/features/config-get-field.feature +++ b/features/config-get-field.feature @@ -335,3 +335,15 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp """ false """ + + When I run `wp config get WP_DEBUG --format=yaml` + Then STDOUT should be: + """ + true + """ + + When I run `wp config get WP_DEBUG_LOG --format=yaml` + Then STDOUT should be: + """ + false + """ From 1eea4129a71ab09850f15c22bab07a34caa3629c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 12 Mar 2026 17:50:31 +0100 Subject: [PATCH 4/5] Apply suggestion from @swissspidy --- features/config-get-field.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/config-get-field.feature b/features/config-get-field.feature index 394ce4e9..b48ead94 100644 --- a/features/config-get-field.feature +++ b/features/config-get-field.feature @@ -339,7 +339,8 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp When I run `wp config get WP_DEBUG --format=yaml` Then STDOUT should be: """ - true + --- + - true """ When I run `wp config get WP_DEBUG_LOG --format=yaml` From 66a67e43efc5d556e20e7e392a09331b219065ad Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 12 Mar 2026 18:37:32 +0100 Subject: [PATCH 5/5] Apply suggestion from @swissspidy --- features/config-get-field.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/config-get-field.feature b/features/config-get-field.feature index b48ead94..c7efc84a 100644 --- a/features/config-get-field.feature +++ b/features/config-get-field.feature @@ -346,5 +346,6 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp When I run `wp config get WP_DEBUG_LOG --format=yaml` Then STDOUT should be: """ - false + --- + - false """