[wp-trac] [WordPress Trac] #21989: update_option() calls sanitize_option() twice when option does not exist
WordPress Trac
noreply at wordpress.org
Tue May 9 02:10:14 UTC 2023
#21989: update_option() calls sanitize_option() twice when option does not exist
-------------------------------------------------+-------------------------
Reporter: MikeSchinkel | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: dev-feedback has-patch needs- | Focuses:
testing | performance
-------------------------------------------------+-------------------------
Comment (by lev0):
11 years old and this just bit me. Crashed a plugin settings save after
install, and never saved any data.
`update_option()` already uses the `$notoptions` cache below the diversion
to `add_option()`, which will contain the name of a new, non-existent
option after the `get_option()` call. If the `get_option()` call was moved
above the `sanitize_option()`, and that cache was read immediately after
that, then that cache could be checked first, and the function diverted to
`add_option()` before the `sanitize_option()`. The issue with that
solution is that new options would no longer go through the
`pre_update_option_{$option}` and `pre_update_option` filters, but options
added with `add_option()` don't either.
Something like this:
https://core.trac.wordpress.org/attachment/ticket/21989/no-double-
handling-2.patch
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21989#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list