[wp-trac] [WordPress Trac] #34689: update_option should not trigger the option_{option name} filter

WordPress Trac noreply at wordpress.org
Mon Nov 16 18:47:42 UTC 2015


#34689: update_option should not trigger the option_{option name} filter
--------------------------+----------------------
 Reporter:  mark-k        |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  General       |     Version:
 Severity:  normal        |  Resolution:  wontfix
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 This seems like a minefield to me. The `get_option()` check in
 `update_option()` is intended to check whether the provided `$value` is
 the same as the existing value of the option. If you have a filter like
 your `my_option()`, then, from WP's point of view, __the value of
 'my_option' *is* '1'__. In your specific case, the filter is conditional -
 `if ( is_single() )`. But, in general, how can WP know whether the value
 returned by the 'option_' filter is the "real" value? It's likely that
 people are using filters like this to *prevent* database hits.

 I'd suggest that conditional filters on 'option_' point toward
 architectural problems in what you're building. You really should be
 filtering something further up the stack. If WP is missing an appropriate
 filter for your purpose, please feel free to request it :)

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


More information about the wp-trac mailing list