[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
Thu Mar 2 21:59:03 UTC 2017
#40007: update_option function does not work if the $value argument is false on a
nonexistent option
--------------------------+------------------------------
Reporter: alexvorn2 | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Comment (by peterwilsoncc):
Converting to `0(int)` instead of `"0"(string)` will result in a database
write on every call, as all options are recorded as strings. The old and
new value comparison becomes `0 === "0"` and evaluates to false. (related
#38903).
A more robust solution would be to correctly cast the value before
comparing old an new values.
It's worth noting `add_option()` will fail to store the value `false` too.
[https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
includes/option.php?marks=410-411#L410 ref].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40007#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list