-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
command:optionRelated to 'option' commandRelated to 'option' command
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
The option list command with the --autoload option does not search for the new on/off values in WordPress Core 6.6, resulting in no return values.
Describe how other contributors can replicate this bug
- perform a fresh installation of WordPress Core 6.6.1
- download the latest WP-CLI version, 2.11
- run
[path to wp-cli.phar] option list --autoload=on - run
[path to wp-cli.phar] option list --autoload=yes - run
[path to wp-cli.phar] option list --autoload=off - run
[path to wp-cli.phar] option list --autoload=no
Describe what you would expect as the correct outcome
I would expect that either:
- searching for on/yes (and off/no) would search for both autoload values
- the new autoload values (on/off) would have their own search values
Let us know what environment you are running this on
$ ./wp-cli.phar cli info
OS: Linux 5.4.245-200.el7.x86_64 #1 SMP Thu Jun 8 15:58:31 EDT 2023 x86_64
Shell: /bin/bash
PHP binary: /opt/remi/php81/root/usr/bin/php
PHP version: 8.1.28
php.ini used: /etc/opt/remi/php81/php.ini
MySQL binary: /bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.5.23-MariaDB, for Linux (x86_64) using readline 5.1
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /chroot/home/ab59ee70/5cb513e4ba.nxcli.io/html
WP-CLI packages dir:
WP-CLI cache dir: /home/ab59ee70/.wp-cli/cache
WP-CLI global config: /home/ab59ee70/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.11.0
$ ./wp-cli.phar core version
6.6.1
Provide a possible solution
The following code could be updated to one of the following:
entity-command/src/Option_Command.php
Lines 275 to 284 in da6f7bf
| if ( isset( $assoc_args['autoload'] ) ) { | |
| $autoload = $assoc_args['autoload']; | |
| if ( 'on' === $autoload || 'yes' === $autoload ) { | |
| $autoload_query = " AND autoload='yes'"; | |
| } elseif ( 'off' === $autoload || 'no' === $autoload ) { | |
| $autoload_query = " AND autoload='no'"; | |
| } else { | |
| WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." ); | |
| } | |
| } |
1 - search for both values:
if ( isset( $assoc_args['autoload'] ) ) {
$autoload = $assoc_args['autoload'];
if ( 'on' === $autoload || 'yes' === $autoload ) {
$autoload_query = " AND (autoload='on') OR autoload='yes')";
} elseif ( 'off' === $autoload || 'no' === $autoload ) {
$autoload_query = " AND (autoload='off' OR autoload='no')";
} else {
WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." );
}
}
2 - split for individual values:
if ( isset( $assoc_args['autoload'] ) ) {
$autoload = $assoc_args['autoload'];
if ( 'on' === $autoload ) {
$autoload_query = " AND autoload='on'";
} elseif ( 'yes' === $autoload ) {
$autoload_query = " AND autoload='yes'";
} elseif ( 'off' === $autoload ) {
$autoload_query = " AND autoload='off'";
} elseif ( 'no' === $autoload ) {
$autoload_query = " AND autoload='no'";
} else {
WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." );
}
}
Provide additional context/Screenshots
$ ./wp-cli.phar option list --autoload=on
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
$ ./wp-cli.phar option list --autoload=yes
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
$ ./wp-cli.phar option list --autoload=off
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
$ ./wp-cli.phar option list --autoload=no
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
Metadata
Metadata
Assignees
Labels
command:optionRelated to 'option' commandRelated to 'option' command