Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/08/2019 08:11:51 PM (6 years ago)
Author:
boonebgorges
Message:

Cast func_get_args() to variable early in class methods.

Since PHP 7.0, calling func_get_args() returns the current value of
the parameter, which may have been modified since the beginning of the
method. By storing the original function arguments in a variable at the
beginning of the method, we ensure that the value operated on later in
the method accurately reflects what was originally passed.

In most cases addressed by this changeset, there was no real-world
possibility that the arguments could be changed; we make this change
mostly as a best practice, and to appease the PHP compatibility linter.

Fixes #8125.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-functions.php

    r12405 r12426  
    240240 */
    241241function groups_edit_base_group_details( $args = array() ) {
     242    $function_args = func_get_args();
    242243
    243244    // Backward compatibility with old method of passing arguments.
    244     if ( ! is_array( $args ) || func_num_args() > 1 ) {
     245    if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    245246        _deprecated_argument( __METHOD__, '2.9.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
    246247
     
    252253        );
    253254
    254         $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
     255        $args = bp_core_parse_args_array( $old_args_keys, $function_args );
    255256    }
    256257
     
    690691 */
    691692function groups_get_group_members( $args = array() ) {
     693    $function_args = func_get_args();
    692694
    693695    // Backward compatibility with old method of passing arguments.
    694     if ( ! is_array( $args ) || func_num_args() > 1 ) {
     696    if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    695697        _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
    696698
     
    705707        );
    706708
    707         $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
     709        $args = bp_core_parse_args_array( $old_args_keys, $function_args );
    708710    }
    709711
     
    721723
    722724    // For legacy users. Use of BP_Groups_Member::get_all_for_group() is deprecated.
    723     if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, func_get_args() ) ) {
     725    if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, $function_args ) ) {
    724726        $retval = BP_Groups_Member::get_all_for_group( $r['group_id'], $r['per_page'], $r['page'], $r['exclude_admins_mods'], $r['exclude_banned'], $r['exclude'] );
    725727    } else {
Note: See TracChangeset for help on using the changeset viewer.