Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion features/option-list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ Feature: List WordPress options
siteurl
"""

@skip-object-cache
Scenario: Using the `--autoload=on` flag excludes transients by default
Given a WP install
And I run `wp option add sample_autoload_option 'sample_autoload_option' --autoload=yes`
And I run `wp transient set sample_autoload_transient 'sample_autoload_transient'`

When I run `wp option list --autoload=on`
Then STDOUT should contain:
"""
sample_autoload_option
"""
And STDOUT should not contain:
"""
sample_autoload_transient
"""

When I run `wp option list --transients --autoload=on`
Then STDOUT should contain:
"""
sample_autoload_transient
"""
And STDOUT should not contain:
"""
sample_autoload_option
"""

Scenario: List option with exclude pattern
Given a WP install

Expand Down Expand Up @@ -198,4 +224,4 @@ Feature: List WordPress options
And STDOUT should contain:
"""
sample_value_four
"""
"""
12 changes: 6 additions & 6 deletions src/Option_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ public function list_( $args, $assoc_args ) {
if ( isset( $assoc_args['autoload'] ) ) {
$autoload = $assoc_args['autoload'];
if ( 'on' === $autoload || 'yes' === $autoload ) {
$autoload_query = " AND (autoload='on') OR (autoload='yes')";
$autoload_query = " AND (autoload='on' OR autoload='yes')";
} elseif ( 'off' === $autoload || 'no' === $autoload ) {
$autoload_query = " AND (autoload='off') OR (autoload='no')";
$autoload_query = " AND (autoload='off' OR autoload='no')";
} else {
WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." );
}
Expand All @@ -306,11 +306,11 @@ public function list_( $args, $assoc_args ) {
$show_transients = Utils\get_flag_value( $assoc_args, 'transients', false );

if ( $show_transients ) {
$transients_query = " AND option_name LIKE '\_transient\_%'
OR option_name LIKE '\_site\_transient\_%'";
$transients_query = " AND (option_name LIKE '\_transient\_%'
OR option_name LIKE '\_site\_transient\_%')";
} else {
$transients_query = " AND option_name NOT LIKE '\_transient\_%'
AND option_name NOT LIKE '\_site\_transient\_%'";
$transients_query = " AND (option_name NOT LIKE '\_transient\_%'
AND option_name NOT LIKE '\_site\_transient\_%')";
}

$where = '';
Expand Down
Loading