Skip to content

Commit b618e95

Browse files
committed
Merge branch 'master' of github.com:wp-cli/entity-command
2 parents 13b4e61 + c0ed184 commit b618e95

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ before_install:
4747
else
4848
echo "xdebug.ini does not exist"
4949
fi
50+
- |
51+
# Raise PHP memory limit to 256MB
52+
echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
5053
5154
install:
5255
- composer require wp-cli/wp-cli:dev-master

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,9 @@ wp option list [--search=<pattern>] [--exclude=<pattern>] [--autoload=<value>] [
17191719
[--transients]
17201720
List only transients. Use `--no-transients` to ignore all transients.
17211721

1722+
[--unserialize]
1723+
Unserialize option values in output.
1724+
17221725
[--field=<field>]
17231726
Prints the value of a single field.
17241727

features/option-list.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,16 @@ Feature: List WordPress options
135135
siteurl
136136
"""
137137

138+
Scenario: Using the `--unserialize` flag
139+
Given a WP install
140+
141+
When I run `wp option add --format=json sample_test_field_one '{"value": 1}'`
142+
And I run `wp option list --search="sample_test_field_*" --format=yaml --unserialize`
143+
Then STDOUT should be:
144+
"""
145+
---
146+
-
147+
option_name: sample_test_field_one
148+
option_value:
149+
value: 1
150+
"""

src/Option_Command.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public function add( $args, $assoc_args ) {
154154
* [--transients]
155155
* : List only transients. Use `--no-transients` to ignore all transients.
156156
*
157+
* [--unserialize]
158+
* : Unserialize option values in output.
159+
*
157160
* [--field=<field>]
158161
* : Prints the value of a single field.
159162
*
@@ -317,6 +320,14 @@ public function list_( $args, $assoc_args ) {
317320
krsort( $results );
318321
}
319322

323+
if ( true === Utils\get_flag_value( $assoc_args, 'unserialize', null ) ) {
324+
foreach ( $results as $k => &$v ) {
325+
if ( ! empty( $v->option_value ) ) {
326+
$v->option_value = maybe_unserialize( $v->option_value );
327+
}
328+
}
329+
}
330+
320331
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'total_bytes' ) {
321332
WP_CLI::line( $results[0]->size_bytes );
322333
} else {

0 commit comments

Comments
 (0)