Skip to content

Commit 27e4798

Browse files
authored
Merge pull request #127 from BhargavBhandari90/issue/121
Default to not showing transients in options list
2 parents 2ef8fad + 8b8d73e commit 27e4798

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

features/option-list.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,21 @@ Feature: List WordPress options
117117
sample_test_field_one,sample_test_field_value_one
118118
"""
119119

120+
Scenario: Default list option without transient
121+
Given a WP install
122+
And I run `wp transient set wp_transient_flag wp_transient_flag`
123+
124+
When I run `wp option list`
125+
Then STDOUT should not contain:
126+
"""
127+
wp_transient_flag
128+
"""
129+
And STDOUT should not contain:
130+
"""
131+
_transient
132+
"""
133+
And STDOUT should contain:
134+
"""
135+
siteurl
136+
"""
137+

src/Option_Command.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ public function list_( $args, $assoc_args ) {
277277
}
278278
}
279279

280+
// By default we don't want to display transients.
281+
$show_transients = Utils\get_flag_value( $assoc_args, 'transients', false );
282+
280283
$transients_query = '';
281-
if ( true === Utils\get_flag_value( $assoc_args, 'transients', null ) ) {
284+
if ( $show_transients ) {
282285
$transients_query = " AND option_name LIKE '\_transient\_%'
283286
OR option_name LIKE '\_site\_transient\_%'";
284-
} else if ( false === Utils\get_flag_value( $assoc_args, 'transients', null ) ) {
287+
} else {
285288
$transients_query = " AND option_name NOT LIKE '\_transient\_%'
286289
AND option_name NOT LIKE '\_site\_transient\_%'";
287290
}

0 commit comments

Comments
 (0)