Arcanist deprecation errors on PHP 8

Arcanist continues to not age well.

For anyone who is experiencing an error like:

$ arc patch D127907                                                                                                                                                             
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated                                                                                                                                 
(Run with `--trace` for a full exception trace.)

This is caused by a deprecation warning being treated as an error. I really hate that I have to know anything about PHP to handle code reviews in LLVM, but apparently, this starts happening after an upgrade to PHP 8. I am already using arcanist as cloned from git, so I just applied the following patch to tell it to use the default error flags (which at least on my machine, disable deprecation warnings in php.ini).

diff --git a/support/init/init-script.php b/support/init/init-script.php
index ad40b8bd..5da2e045 100644
--- a/support/init/init-script.php
+++ b/support/init/init-script.php
@@ -15,7 +15,7 @@ function __arcanist_init_script__() {
-  error_reporting(E_ALL | E_STRICT);
+  //error_reporting(E_ALL | E_STRICT);
   $config_map = array(
     // Always display script errors. Without this, they may not appear, which is

This is helpful. Thanks !

Just FYI, for arc diff the following patch may be needed for some newer PHP versions

diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php
index 7201a003..808dc9bd 100644
--- a/src/workflow/ArcanistDiffWorkflow.php
+++ b/src/workflow/ArcanistDiffWorkflow.php
@@ -2360,6 +2360,9 @@ EOTEXT

     // If we track an upstream branch either directly or indirectly, use that.
     $branch = $api->getBranchName();
+    if (is_null($branch)) {
+        $branch = '';
+    }
     if (strlen($branch)) {
       $upstream_path = $api->getPathToUpstream($branch);
       $remote_branch = $upstream_path->getRemoteBranchName();

It’s also quite straight-forward to use the Phabricator API for the main tasks. For example, I’ve been using the following script as replacement for arc patch: ⚙ D73075 [utils] Add initial llvm-patch helper to manage patches. (with the caveat that it only supports patches that apply cleanly)


I’ve had some success using moz-phab to interact with Phabricator instead of arcanist. I haven’t switched to it as my daily driver yet out of sheer laziness, but it worked pretty well for everything I tried.