1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 00:02:40 +01:00

In "array_mergev()", guarantee the "call_user_func_array()" parameter list is a natrual list

Summary:
Ref T13588. The behavior of "call_user_func_array()" has changed in PHP8, and the function now attempts to use array keys as argument names.

This always fails when calling "array_merge()" (which does not accept named parameters), and may cause misbehavior in the general case.

Guarantee the argument is a natural list (with keys "0", "1", "2", ...).

Test Plan:
  - Behavior unchanged under PHP7.
  - User reports fixed behavior under PHP8, see <https://discourse.phabricator-community.org/t/daemon-fails-on-php-8-0-2-in-utils-php-array-merge-call-w-fix/4568>.
  - See T13588.

Maniphest Tasks: T13588

Differential Revision: https://secure.phabricator.com/D21551
This commit is contained in:
epriestley 2021-02-08 10:13:29 -08:00
parent 32fe933f3a
commit 239ad5c55d

View file

@ -876,14 +876,19 @@ function array_mergev(array $arrayv) {
if (!is_array($item)) {
throw new InvalidArgumentException(
pht(
'Expected all items passed to `%s` to be arrays, but '.
'Expected all items passed to "array_mergev()" to be arrays, but '.
'argument with key "%s" has type "%s".',
__FUNCTION__.'()',
$key,
gettype($item)));
}
}
// See T13588. In PHP8, "call_user_func_array()" will attempt to use
// "unnatural" array keys as named parameters, and then fail because
// "array_merge()" does not accept named parameters . Guarantee the list is
// a "natural" list to avoid this.
$arrayv = array_values($arrayv);
return call_user_func_array('array_merge', $arrayv);
}