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

WordPress Trac noreply at wordpress.org
Sun Nov 15 18:02:29 UTC 2015


#34689: update_option should not trigger the option_{option name} filter
--------------------------+-----------------------------
 Reporter:  mark-k        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 example code will illustrate the problem best


 {{{
 function my-option($v) {
   if (is_single() {
     return '1';
   }

   return $v;
 }

 add_filter('option_my_option','my_option');

 }}}

 now somewhere in a single.php of a theme


 {{{
 update_option('my_option','1');

 }}}

 will not write to the DB since the code will detect that the value wasn't
 changed.

 I guess this is an extreme rare case in practice, but it seems like either
 get_option should get a 'raw' parameter and ignore filters, or
 update_option should get the raw value in another way.

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


More information about the wp-trac mailing list