[wp-trac] Re: [WordPress Trac] #2584: do_action merges array args, causing data loss prior to callback

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 21 08:14:45 GMT 2006


#2584: do_action merges array args, causing data loss prior to callback
----------------------------+-----------------------------------------------
       Id:  2584            |      Status:  new                     
Component:  Administration  |    Modified:  Tue Mar 21 08:14:45 2006
 Severity:  normal          |   Milestone:                          
 Priority:  normal          |     Version:  2.0.2                   
    Owner:  anonymous       |    Reporter:  skeltoac                
----------------------------+-----------------------------------------------
Comment (by random):

 What's the expected behaviour and what's happening instead?

 {{{
 function myfunction() {
         print_r(func_get_args());
         die();
 }
 // -1 == pass all arguments
 add_action('myaction', 'myfunction', 1, -1);
 do_action('myaction', array('1', '2', '3'), array('4', '5'));
 }}}

 returns

 {{{
 Array
 (
     [0] => 1
     [1] => 2
     [2] => 3
     [3] => Array
         (
             [0] => 4
             [1] => 5
         )

 )
 }}}

 which it seems to have been carefully designed to do. I think the
 apply_filters behaviour is better (passing arrays directly), but don't see
 the data loss. (Sorry if I've missed something or misread you!)

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


More information about the wp-trac mailing list