Repository navigation
wp option list --autoload misses options stored as auto, auto-on or auto-off #670
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
Since WordPress 6.6, an option that is saved without an explicit autoload value gets auto in the autoload column. It gets auto-off when the value is large (over 150000 bytes), and auto-on or auto-off when the wp_default_autoload_value filter decides. See wp_determine_option_autoload_value(). WordPress autoloads auto and auto-on options, see wp_autoload_values_to_autoload().
wp option list --autoload=on only matches on and yes. wp option list --autoload=off only matches off and no. So options with auto, auto-on or auto-off are in neither list.
This is not rare. On a fresh WordPress 7.2-beta1 install, after the first load, 16 core options have auto (sidebars_widgets and the widget_* options). WordPress autoloads them, but --autoload=on leaves them out. wp option update for a new option also creates an auto option. The documented example wp option list --autoload=on --format=total_bytes ("Get the total size of all autoload options") reports a smaller size than what WordPress really autoloads.
Describe how other contributors can replicate this bug
- Use WordPress 6.6 or later. I used 7.2-beta1-64691.
wp option update demo_auto_option demo_valuewp option get-autoload demo_auto_optionprintsauto, andwp_load_alloptions()contains the option.wp option list --autoload=on --search="demo_*"does not list it.wp option list --autoload=off --search="demo_*"does not list it either.head -c 200000 /dev/zero | tr "\0" a | wp option update demo_big_optionstores the option withauto-off.wp option list --autoload=off --search="demo_*"does not list it.
$ wp option update demo_auto_option demo_value
Success: Updated 'demo_auto_option' option.
$ wp option get-autoload demo_auto_option
auto
$ wp eval 'var_dump( array_key_exists( "demo_auto_option", wp_load_alloptions() ) );'
bool(true)
$ wp option list --autoload=on --search="demo_*"
option_name option_value
$ wp option list --autoload=off --search="demo_*"
option_name option_value
$ head -c 200000 /dev/zero | tr "\0" a | wp option update demo_big_option
Success: Updated 'demo_big_option' option.
$ wp option get-autoload demo_big_option
auto-off
$ wp option list --autoload=off --search="demo_*" --fields=option_name,autoload
option_name autoload
$ wp db query "SELECT autoload, COUNT(*) FROM wp_options GROUP BY autoload"
autoload COUNT(*)
auto 17
auto-off 1
off 9
on 101
$ wp option list --format=count
124
$ wp option list --autoload=on --format=count
99
$ wp option list --autoload=off --format=count
7
99 + 7 is 106, so 18 of the 124 listed options are missing from both lists: the 16 core options with auto, plus the two options above. The counts in the database query include transients, which wp option list hides by default.
Describe what you would expect as the correct outcome
--autoload=on lists every option that WordPress autoloads, so auto and auto-on options too. --autoload=off lists every option that WordPress does not autoload, so auto-off options too. Every option is in exactly one of the two lists.
Let us know what environment you are running this on
OS: Linux 6.18.33.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026 x86_64
Shell: /bin/sh
PHP binary: /usr/local/bin/php
PHP version: 8.5.9
PHP memory limit: -1
php.ini used: /usr/local/etc/php/php-cli.ini
MySQL binary: /usr/bin/mariadb
MySQL version: mariadb from 11.8.9-MariaDB, client 15.2 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: phar:///tmp/wp-cli-nightly.phar
WP-CLI packages dir:
WP-CLI cache dir: /tmp/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 3.0.0-alpha-836ccac
WordPress 7.2-beta1-64691, MariaDB 11.8.9. I see the same result with WP-CLI 2.12.0 and with entity-command main at 2078d6a.
Provide a possible solution
Use wp_autoload_values_to_autoload() for the list of autoloaded values, the same list wp_load_alloptions() uses. Then --autoload=on becomes autoload IN (...) and --autoload=off becomes autoload NOT IN (...). On WordPress before 6.6 the function does not exist, so fall back to on and yes.
I have a patch with a Behat test and can open a PR.
Provide additional context/Screenshots
#509 and #515 added the on and off values to this filter. The three auto values from WordPress 6.6 are the part that is still missing.
Activity