[wp-trac] [WordPress Trac] #21989: update_option() calls sanitize_option() twice when option does not exist
WordPress Trac
noreply at wordpress.org
Mon Jul 7 06:40:37 UTC 2014
#21989: update_option() calls sanitize_option() twice when option does not exist
--------------------------------------------------+------------------
Reporter: MikeSchinkel | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.0
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: dev-feedback has-patch needs-testing | Focuses:
--------------------------------------------------+------------------
Comment (by rmccue):
Replying to [comment:12 Denis-de-Bernardy]:
> Hold... Did you just seriously argue that maintaining backwards compat
on broken was important? ;-)
The brokenness here only occurs for options with a sanitization callback;
others are unaffected. Breaking a working hook for them here would be bad.
:)
> I for one ink that adding a new argument borders on crazy, so I'd rather
see my own patch get checked in.
The new argument was so that we can maintain BC with the
`pre_update_option` hooks rather than passing through early. With that
said:
> As an aside, don't miss what I highlighted as I submitted it: the order
of these filters and such differ in update_option and update_site_option
-- and other options and transient related functions, for that matter.
Interesting, I had missed that, apologies. `update_site_option` calls
`pre_update_option_{$option}` but not `pre_update_option`. These should
all be made consistent, obviously (that's probably a separate ticket,
IMO).
`update_site_option` calls `sanitize_option` '''after'''
`pre_update_option_{$option}`, so that's broken. Given that it's broken
there, we might as well ignore the BC break and go with the filter-then-
sanitize choice for consistency's sake. (Although multisite use with
`update_site_option` is less common, filter-then-sanitize feels like the
more correct way to do it.)
In which case, I endorse [attachment:21989.diff]. :) We should also fix
these crazy filters.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21989#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list