[buddypress-trac] [BuddyPress] #3797: Refactor database methods to accept array-style arguments

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Dec 7 14:15:11 UTC 2011


#3797: Refactor database methods to accept array-style arguments
--------------------------+-----------------------------
 Reporter:  boonebgorges  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Core          |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+-----------------------------

Comment (by boonebgorges):

 Yeah, I guess that makes sense, actually - if we add more defaults to the
 array in the future, my method will break older plugins. So something
 like:

 {{{
 if ( count( func_get_args() ) > 1 ) {
         foreach( func_get_args() as $arg_key => $arg ) {
                 if ( 0 != $arg_key ) {
                         _deprecated_argument( $arg, __( 'Arguments should
 be passed as an array.', 'buddypress' ), '1.6' );
                 }
         }

         $args = array(
                 'type' => func_get_arg(0),
                 'per_page' => func_get_arg(1),
                 // etc
         );
 } else {
         $args = func_get_arg( 0 );
 }

 $defaults = array( ... );
 $r = wp_parse_args( $args, defaults );
 extract( $r );
 }}}

 I'm using func_get_arg() because I assume that we will change the
 parameter names in the function definition to $deprecated1, $deprecated2
 (or remove them altogether) so that devs aren't encouraged to use them
 when they look at the source.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3797#comment:4>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list