Daemon Fails on PHP 8.0.2 in utils.php:array_merge() call (w/ fix)

Reproduction Instructions

  • Pull arcanist to 32fe933f3ae75cf8ad2019425cc1a550e02b6894 and phabricator to 00cf93548b70a2a98dcbc2763f00bfa3c2601d7b (both repos sibling to each other)
  • Run phabricator/bin/phd start
  • Observe the exception with callstack:
Feb 08 11:01:04 bank phd[3508623]: [2021-02-08 11:01:04] EXCEPTION: (ArgumentCountError) array_merge() does not accept unknown named parameters at [<arcanist>/src/utils/utils.php:887]
Feb 08 11:01:04 bank phd[3508623]: arcanist(head=master, ref.master=32fe933f3ae7), phabricator(head=master, ref.master=00cf93548b70)
Feb 08 11:01:04 bank phd[3508623]:   #0 array_merge(array, array, array, array) called at [<arcanist>/src/utils/utils.php:887]
Feb 08 11:01:04 bank phd[3508623]:   #1 array_mergev(array) called at [<phabricator>/src/applications/base/PhabricatorApplication.php:364]
Feb 08 11:01:04 bank phd[3508623]:   #2 PhabricatorApplication::getAllApplications() called at [<phabricator>/src/applications/base/PhabricatorApplication.php:373]
Feb 08 11:01:04 bank phd[3508623]:   #3 PhabricatorApplication::getAllInstalledApplications() called at [<phabricator>/src/infrastructure/events/PhabricatorEventEngine.php:30]
Feb 08 11:01:04 bank phd[3508623]:   #4 PhabricatorEventEngine::initialize() called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:133]
Feb 08 11:01:04 bank phd[3508623]:   #5 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:75]
Feb 08 11:01:04 bank phd[3508623]:   #6 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phabricator>/scripts/init/lib.php:26]
Feb 08 11:01:04 bank phd[3508623]:   #7 init_phabricator_script(array) called at [<phabricator>/scripts/init/init-script.php:9]
Feb 08 11:01:04 bank phd[3508623]:   #8 require_once(string) called at [<phabricator>/scripts/__init_script__.php:3]
Feb 08 11:01:04 bank phd[3508623]:   #9 require_once(string) called at [<phabricator>/scripts/daemon/manage_daemons.php:5]
Feb 08 11:01:04 bank systemd[1]: phabricator-phd.service: Control process exited, code=exited, status=255/EXCEPTION

PHP Version

matt@bank /s/p/phabricator (master)> php -v
PHP 8.0.2 (cli) (built: Feb  2 2021 18:26:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies

Phabricator/Arcanist Version

matt@bank /s/p/arcanist (master) [1]> bin/arc version
arcanist 32fe933f3ae75cf8ad2019425cc1a550e02b6894 (3 Feb 2021)

Proposed Fix

diff --git a/src/utils/utils.php b/src/utils/utils.php
index 4c44d7b7..85331258 100644
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -884,7 +884,7 @@ function array_mergev(array $arrayv) {
-  return call_user_func_array('array_merge', $arrayv);
+  return call_user_func_array('array_merge', array_values($arrayv));

I also found that there is a call to a removed function for Phabricator itself. Quick fix/hack:

diff --git a/support/startup/PhabricatorStartup.php b/support/startup/PhabricatorStartup.php
index 870d342464..87e772c750 100644
--- a/support/startup/PhabricatorStartup.php
+++ b/support/startup/PhabricatorStartup.php
@@ -521,13 +521,13 @@ final class PhabricatorStartup {
-    if (@get_magic_quotes_gpc()) {
+    /*if (@get_magic_quotes_gpc()) {
         "Your server is configured with PHP 'magic_quotes_gpc' enabled. This ".
         "feature is 'highly discouraged' by PHP's developers and you must ".
         "disable it to run Phabricator. Consult the PHP manual for ".
-    }
+    }*/
     if (extension_loaded('apc')) {
       $apc_version = phpversion('apc');

With the two fixes in this thread, Phabricator is working on PHP8 for us, but we’re not really advanced users at all.

What’s the actual error or warning message the array_merge() call produces? It looks like it might have gotten cut off in the stack trace (or I just missed it?) – I’m not sure exactly what PHP8 is complaining about, and there may be more instances of whatever it is elsewhere.

Your first fix is likely correct.

Your second fix is likely correct in spirit, and I’ll probably upstream an if (function_exists(...)) variation.

I’ve upstreamed a variant of the second fix in https://secure.phabricator.com/D21549.

1 Like

Sorry about that! I have updated the log output to include the actual error message.

Thanks! It looks like this is the root issue, which isn’t great:

I’ll follow up in https://secure.phabricator.com/T13588 and likely apply some functional equivalent of your patch shortly.

1 Like

I added some more details about the PHP-level language change causing this problem to https://secure.phabricator.com/T13588.

I upstreamed a functionally identical fix for the specific call_user_func_array() issue in array_mergev() in https://secure.phabricator.com/D21551.

Thanks for the report!

Thank you! I have pulled both projects and can confirm things continue to work well in PHP 8.0.2.