[wp-trac] [WordPress Trac] #30875: enforce integers in add_filter priority

WordPress Trac noreply at wordpress.org
Thu Jan 1 02:18:24 UTC 2015


#30875: enforce integers in add_filter priority
--------------------------+------------------------------
 Reporter:  drrobotnik    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:  4.1
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------
Changes (by dd32):

 * keywords:  needs-refresh => close
 * component:  General => Plugins


Comment:

 The problem with this, in a similar manner to #30862 is that changing this
 potentially breaks existing implementations.

 For example, with this code, all the actions will be called (in a
 predictable order, although not exactly the order one would expect), but
 if your patch is applied only the int case will be actually added.

 {{{
 function _test_int() { echo __METHOD__ . "\n"; }
 function _test_int_as_string() { echo __METHOD__ . "\n"; }
 function _test_float() { echo __METHOD__ . "\n"; }
 function _test_float_as_string() { echo __METHOD__ . "\n"; }
 function _test_string() { echo __METHOD__ . "\n"; }

 add_action( 'test_action', '_test_int', 10 );
 add_action( 'test_action', '_test_int_as_string', '9' );
 add_action( 'test_action', '_test_float', 8.1 );
 add_action( 'test_action', '_test_float_as_string', '7.2' );
 add_action( 'test_action', '_test_string', 'micky' );

 echo '<pre>';
 do_action( 'test_action' );
 }}}

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


More information about the wp-trac mailing list