Title: Does not update `false` values
Last modified: August 6, 2020

---

# Does not update `false` values

 *  Resolved [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/does-not-update-false-values/)
 * Hi!
 * We have noticed some strange behavior with Redis Object Cache. If the cache **
   is enabled** we can not update checkboxes to a `false` state in our `wp_options`
   database table. You can run into the issue with the following example:
 *     ```
       add_action('customize_register', function ($wp_customize) {
           add_option('testc_checkbox_setting_id', true);
           $wp_customize->add_setting('testc_checkbox_setting_id', [
               'type' => 'option',
               'sanitize_callback' => function ($checked) {
                   return isset($checked) && true == $checked ? true : false;
               }
           ]);
   
           $wp_customize->add_control('testc_checkbox_setting_id', [
               'type' => 'checkbox',
               'section' => 'static_front_page',
               'label' => __('Custom Checkbox'),
               'description' => __('This is a custom checkbox input.'),
               'settings' => 'testc_checkbox_setting_id'
           ]);
       });
       ```
   
 * This code simply registers a new checkbox in **Design > Customizer > Homepage
   Settings > “CUSTOM CHECKBOX”**. If you try now to deactivate the checkbox (state:
   not checked), the value never gets updated in the database.
 * If we deactivate the Redis object cache, all is working fine.
 *     ```
       Status: Connected
       Client: PhpRedis (v5.2.2)
       Drop-in: Valid
       Disabled: No
       Filesystem: Working
       Ping: 1
       Errors: []
       PhpRedis: 5.2.2
       Predis: Not loaded
       Credis: Not loaded
       PHP Version: 7.4.6
       Plugin Version: 2.0.8
       Redis Version: 6.0.3
       Multisite: No
       Global Prefix: "wp_"
       Blog Prefix: "wp_"
       WP_REDIS_HOST: "redis"
       WP_REDIS_MAXTTL: "14400"
       WP_REDIS_PREFIX: "wp.io_obj:"
       WP_CACHE_KEY_SALT: "wp.io_obj:"
       Global Groups: [
           "blog-details",
           "blog-id-cache",
           "blog-lookup",
           "global-posts",
           "networks",
           "rss",
           "sites",
           "site-details",
           "site-lookup",
           "site-options",
           "site-transient",
           "users",
           "useremail",
           "userlogins",
           "usermeta",
           "user_meta",
           "userslugs",
           "blog_meta"
       ]
       Ignored Groups: [
           "counts",
           "plugins",
           "themes",
           "mailster",
           "WPML_ST_Package_Factory"
       ]
       Unflushable Groups: []
       Drop-ins: [
           "maintenance.php v by ",
           "Redis Object Cache Drop-In v2.0.8 by Till Krüss"
       ]
       ```
   
 * Regards,
    Matthew 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13244124)
 * I never got an email notification for this.
 * This is weird, have you tried to re-product this on a clean WP installation?
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13248584)
 * Hi [@tillkruess](https://wordpress.org/support/users/tillkruess/) !
 * Yeah, I tried this on a clean installation.
 * Just give the example code above a chance and you will encounter this issue.
 * Regards,
    Matthew 🙂
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13251357)
 * If you remove `add_option('testc_checkbox_setting_id', true);` that code snippet
   works fine for me on 2.0.10. Saves the state of the checkbox 👍🏻
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13321098)
 * Hi again!
 * Unfortunately I can not remove the `add_option` as it is neede for `autoload`
   functionality of `wp_options` table itself. Can you still save the state “unchecked”
   without `add_option` functionality?
 * Regards,
    Matthew 🙂
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13323716)
 * In that case, it’s not working because your code is broken 👍🏻
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13323779)
 * Hi again!
 * How can the code be broken? `add_option` only adds the option to database when
   it is not already written.
 * Regards,
    Matthew 🙂
 *  Plugin Author [Till Krüss](https://wordpress.org/support/users/tillkruess/)
 * (@tillkruess)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13323897)
 * You should not set options in your `customize_register` action.
 * If you want to debug why it’s not working with Redis, try using `redis-cli monitor`
   and see what happens when `add_option()` is called.
 *  Thread Starter [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * (@mguenter)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13326341)
 * Hi again!
 * I really thought I was technically good at WordPress, but you never stop learning.
   This really solves the problem. Thanks for the great tip and have a nice weekend!
   🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Does not update `false` values’ is closed to new replies.

 * ![](https://ps.w.org/redis-cache/assets/icon-256x256.gif?rev=2568513)
 * [Redis Object Cache](https://wordpress.org/plugins/redis-cache/)
 * [Support Threads](https://wordpress.org/support/plugin/redis-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/redis-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redis-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redis-cache/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Matthias Günter](https://wordpress.org/support/users/mguenter/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/does-not-update-false-values/#post-13326341)
 * Status: resolved