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-xprofile/classes/class-bp-xprofile-data-template.php

    r11363 r12426  
    124124     */
    125125    public function __construct( $args = '' ) {
     126        $function_args = func_get_args();
    126127
    127128        // Backward compatibility with old method of passing arguments.
    128         if ( ! is_array( $args ) || func_num_args() > 1 ) {
     129        if ( ! is_array( $args ) || count( $function_args ) > 1 ) {
    129130            _deprecated_argument( __METHOD__, '2.3.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__ ) );
    130131
     
    142143            );
    143144
    144             $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
     145            $args = bp_core_parse_args_array( $old_args_keys, $function_args );
    145146        }
    146147
Note: See TracChangeset for help on using the changeset viewer.