[wp-trac] [WordPress Trac] #31047: Option nonexistence should not be checked against false

WordPress Trac noreply at wordpress.org
Mon Jan 19 20:06:12 UTC 2015


#31047: Option nonexistence should not be checked against false
-------------------------------------+------------------
 Reporter:  GregLone                 |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.2
Component:  Options, Meta APIs       |     Version:  3.4
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+------------------

Comment (by boonebgorges):

 > Is #22192 a duplicate?

 No. #22192 is a typecasting issue. Scalar option/meta values are always
 going to be cast to string when pulled from the database and stored in the
 cache. So when we compare old values against new values in the `update_`
 functions (eg at https://core.trac.wordpress.org/browser/tags/4.1/src/wp-
 includes/meta.php#L190) we should either (a) do `==` instead of `===`, or
 (b) `if ( is_scalar( $meta_value ) ) $_meta_value = (string) $meta_value;`
 (I'm guessing (b) is safer, but we need unit tests to describe it.)

 This issue is related to the use of the `"default_option_$option"` filter.
 The bug is that if you use this filter, and the 'alloptions' cache is not
 populated, it's impossible to add/update the option.

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


More information about the wp-trac mailing list