Added a 'raw' format to the option get command#446
Added a 'raw' format to the option get command#446shawnhooper wants to merge 1 commit intowp-cli:mainfrom
Conversation
… as stored in the database
|
A direct database query won't work if an external database cache is involved, because then WordPress provides a |
What if we called it |
While still using a direct database query? Then that sounds more like |
|
Hm, maybe this enhancement is a bad idea then... |
|
Alright, so It would be roughly equivalent to Alternatively, if we do $value = get_option( $key );
if ( 'raw' === Utils\get_flag_value( $assoc_args, 'format' ) ) {
return maybe_serialize( $value );
}the only drawback is that the option value that could be filtered by a plugin, so it might not exactly match what's in the db. |
|
I'm leaning towards wontfix. I don't think the original use case is all that common. When it's necessary, the user can use @johnbillion Thoughts? |
|
I think I opened my original issue because |
|
This works fine too: |
|
Still leaning towards wontfix here? |
wontfix would be my preference |
|
OK let's close this as a wontfix then. @shawnhooper Thanks nonetheless for your contribution! |
Fixes: #165
Adds a
--format=rawresponse to thewp option getcommand that returns the value as stored in the database. Used if you want to get the an option in PHP serialized format.NOTE: I used the
$wpdb->get_var()command instead of serializing the$valuereturned fromget_optionbecause the latter threw an error when running PHP CodeSniffer: