Closed BlairCooper closed 9 months ago
I miss understood the option I was dealing with in WordPress in reporting this issue. Turns out the option is an array that was serialized before being passed to update_option, making it a string. I'll submit a new enhancement request for supporting pluck and patch on JSON serialized options.
Bug Report
Describe the current, buggy behavior
The documentation for the "option pluck" and "option patch" commands suggest that they work with arrays and JSON. Specifically the reference to 'keys within the value'. However they do not.
Assuming my_option has a value of a:1:{s:5:"myKey";s:6:"aValue";}
The command
wp option pluck my_option myKey
returns nothing.The command
wp option patch update my_option myKey newValue
returnsDescribe how other contributors can replicate this bug
Pluck:
wp option pluck my_option myKey
Patch
wp option patch update my_option myKey newValue
Describe what you would expect as the correct outcome
It should be possible to read a value from an option stored as a serialized array or JSON. It should be possible to write a new value into an option stored as a serialized array or JSON.
Let us know what environment you are running this on
Windows 10, PHP8.2.15
Provide a possible solution
Add detection for and handling of serialized values in options. I have a pull request incoming.
Provide additional context/Screenshots
n/a