Libphutil: Exception when using with newer PHP (deprecated use of `implode()')


Reproduction Instructions
Running arc on a newer version of PHP (i.e. 7.4) throws a lot of exceptions. This is currently a cosmetic issue, but will cause real errors in the future.

[2019-09-30 07:00:39] ERROR 8192: implode(): Passing glue string after array is deprecated. Swap the parameters at [/usr/local/lib/php/libphutil/src/utils/utils.php:1706]
arcanist(), phutil()
  #bug 0 implode(array, string) called at [<phutil>/src/utils/utils.php:1706]
  #1 phutil_build_http_querystring_from_pairs(array) called at [<phutil>/src/utils/utils.php:1678]
  #2 phutil_build_http_querystring(array) called at [<phutil>/src/future/http/HTTPSFuture.php:656]
  #3 HTTPSFuture::formatRequestDataForCURL() called at [<phutil>/src/future/http/HTTPSFuture.php:280]
  #4 HTTPSFuture::isReady() called at [<phutil>/src/future/Future.php:37]
  #5 Future::resolve(NULL) called at [<phutil>/src/future/FutureProxy.php:34]
  #6 FutureProxy::resolve() called at [<phutil>/src/conduit/ConduitClient.php:64]
  #7 ConduitClient::callMethodSynchronous(string, array) called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:518]
  #8 ArcanistDiffWorkflow::run() called at [<arcanist>/scripts/arcanist.php:394]

The documentation in says:

implode ( string $glue , array $pieces ) : string

Note: implode() can, for historical reasons, accept its parameters
in either order. For consistency with explode(), however, it may
be less confusing to use the documented order of arguments.

Phabricator/Arcanist Version

Output from Config > Version Information or arc version.
latest from git

Patch to address the issue (swap arguments):

diff --git a/src/utils/utils.php b/src/utils/utils.php
index 1c5113f8..d04fdf4e 100644
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -1703,7 +1703,7 @@ function phutil_build_http_querystring_from_pairs(array $pairs) {
     list($key, $value) = phutil_http_parameter_pair($key, $value);
     $query[] = rawurlencode($key).'='.rawurlencode($value);
-  $query = implode($query, '&');
+  $query = implode('&', $query);
   return $query;

Thanks! This should be fixed by

1 Like