Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

#8125 closed defect (bug) (fixed)

func_get_args() should be cast to variable before being modified

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 5.0.0 Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

The behavior of func_get_args() was changed in PHP 7.0, so that it reflects the current value of function params, rather than the values originally passed. In cases where we use func_get_args(), intending to reference the original values, we should cast to a variable early in the function. See https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified

Change History (1)

#1 @boonebgorges
5 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 12426:

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.

Note: See TracTickets for help on using tickets.