[wp-trac] [WordPress Trac] #40007: update_option function does not work if the $value argument is false on a nonexistent option

WordPress Trac noreply at wordpress.org
Mon Oct 30 23:49:08 UTC 2023


#40007: update_option function does not work if the $value argument is false on a
nonexistent option
--------------------------+------------------------------
 Reporter:  alexvorn2     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by peterwilsoncc):

 I rediscovered this while working on another ticket.

 In [attachment:"40007.diff"], rather than checking the return value of
 `get_option()` to determine if `update_option()` is called with a new
 option, it checks if the option name appears in the `notoptions` cache.

 If the option key is in `notoptions` then the option can be added to the
 database via the `add_option` function.

 The attached diff is only lightly tested, a call to `update_option( 'non-
 exisistent-option', false )` does result in the option being added to the
 database.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40007#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list