Conversation
The method just return cast `$this->options` as array but actually `$this->options` assign before still a string in some case. Bugs will be show when I try empty cmb setting in `wp_options` table.
|
You will need to write unit tests to prove/test your scenario. |
|
Added unit tests |
|
I just ran the tests you wrote with and without the changes you made in |
|
Thank you for your PR. I have actually merged it to get your unit tests (and given you props), but I reverted the |
|
I miss forgot line in last commit: public function setUp() {
...
add_option( 'cmb_empty_option', '' );
}See the unit tests failures: The bug is because this $this->options = get_option( $this->key, $default );
...
return (array) $this->options;and on public function remove( $field_id, $resave = false ) {
$this->get_options();
if ( isset( $this->options[ $field_id ] ) ) {
unset( $this->options[ $field_id ] );
}If some reasons, I have a option with empty string (or nothing value). And call Because you only cast when return options. Actually |
…not just the return. Fixes #993
|
Ah, now I understand! ed2e58f should address that specific issue. Thank you for providing more info/clarification. |

The method just return cast
$this->optionsas array but actually$this->optionsassign before still a string in some case.Bugs will be show when I try empty cmb setting in
wp_optionstable.