-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a 'raw' format to the option get command #446
Added a 'raw' format to the option get command #446
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=raw
response to thewp option get
command 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$value
returned fromget_option
because the latter threw an error when running PHP CodeSniffer: