[wp-trac] [WordPress Trac] #41099: update_option return value ambiguous

WordPress Trac noreply at wordpress.org
Tue Jun 20 19:57:45 UTC 2017


#41099: update_option return value ambiguous
--------------------------------+------------------------------
 Reporter:  cloughit            |       Owner:
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Options, Meta APIs  |     Version:  4.8
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:
--------------------------------+------------------------------

Comment (by mdifelice):

 Hi @cloughit I had the same problem, and I think that update_option should
 return NULL also when no option is set, but that kind of change would have
 such a big impact that it would be necessary to update a lot of files.

 My problem happened using the cache functions. All options are cached by
 the object cache plugin (if you are using it), but if you save a false
 value in the option the cache plugin interprets that the options is not
 cached and it tries to fetch it from the database. So, any option with the
 false value is not being cached in practice.

 The solution I found is using string values: "yes" or "no". In fact,
 WordPress uses those values for its boolean options and I guess that the
 reason to do that is to identify if the options was created or not. It is
 not ideal, because you are using more space to store and transfer the
 options but I guess this is the only solution for now.

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


More information about the wp-trac mailing list