Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp option - autoload filter doesn't display new autoload values #509

Open
2 tasks done
jhagrid77 opened this issue Aug 16, 2024 · 1 comment · May be fixed by #515
Open
2 tasks done

wp option - autoload filter doesn't display new autoload values #509

jhagrid77 opened this issue Aug 16, 2024 · 1 comment · May be fixed by #515

Comments

@jhagrid77
Copy link

Bug Report

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:

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 |
+-------------+--------------+
+-------------+--------------+
@swissspidy
Copy link
Member

Good catch, thanks!

@imrraaj imrraaj linked a pull request Oct 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants