[wp-trac] [WordPress Trac] #18914: register_setting() sanitisation callback two argument backwards incompatibility

WordPress Trac wp-trac at lists.automattic.com
Wed Oct 12 10:27:10 UTC 2011


#18914: register_setting() sanitisation callback two argument backwards
incompatibility
--------------------------+-----------------------
 Reporter:  duck_         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  high          |  Milestone:  3.3
Component:  General       |    Version:  3.3
 Severity:  major         |   Keywords:  has-patch
--------------------------+-----------------------
 See #15335 and [18887] for the introduction of always passing two
 arguments to the sanitisation callback. This is a problem because it
 breaks plugins which use register_setting with a sanitisation callback
 which chokes on the 2nd argument being introduced. An example of this is
 provided on the
 [http://codex.wordpress.org/Function_Reference/register_setting#Example
 codex]:

 {{{
 register_setting( 'my_options_group', 'my_option_name', 'intval' );
 }}}

 One plugin which uses this is bbPress. I was able trigger this on
 activation on a fresh install:

 {{{
 Warning: intval() expects parameter 2 to be long, string given in wp-
 includes/plugin.php on line 170
 call_user_func_array('intval', array (0 => '5', 1 => '_bbp_edit_lock'))
 wp-includes/plugin.php:170
 }}}

 Attached is a patch to revert the change.

 The only issue is how to address the reason for the code change: "You
 should be able to have a generic save handler that does a switch on the
 option name and does your sanitization magic." A generic sanitize_option
 filter would do it, but would incur some overhead on having the "generic
 save handler" called for every option.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18914>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list