File: 0001-Fix-PHP-8.1-incompatibility-with-arc-patch-D-12345.patch

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,634,820 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (70 lines) | stat: -rw-r--r-- 3,616 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From bb2e9a0394a48f4ef3576e8d91607e8129b2b716 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers@google.com>
Date: Fri, 8 Jul 2022 14:55:46 -0700
Subject: [PATCH] Fix PHP 8.1 incompatibility with `arc patch D<12345>`

Fixes the following observed error with PHP 8.1:

  EXCEPTION: (RuntimeException) preg_match(): Passing null to parameter phacility#2 ($subject) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  arcanist(head=master, ref.master=acec17af414f)
    #0 PhutilErrorHandler::handleError(integer, string, string, integer)
    phacility#1 preg_match(string, NULL, NULL) called at [<arcanist>/src/repository/api/ArcanistGitAPI.php:603]
    phacility#2 ArcanistGitAPI::getCanonicalRevisionName(NULL) called at [<arcanist>/src/repository/api/ArcanistGitAPI.php:1146]
    phacility#3 ArcanistGitAPI::hasLocalCommit(NULL) called at [<arcanist>/src/workflow/ArcanistPatchWorkflow.php:433]
    phacility#4 ArcanistPatchWorkflow::run() called at [<arcanist>/src/workflow/ArcanistPatchWorkflow.php:398]
    phacility#5 ArcanistPatchWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]

Link: https://secure.phabricator.com/book/phabcontrib/article/contributing_code/
Link: https://reviews.llvm.org/D129232#3634072
Suggested-by: Yuanfang Chen <yuanfang.chen@sony.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 src/differential/ArcanistDifferentialDependencyGraph.php | 3 ++-
 src/lint/linter/ArcanistScriptAndRegexLinter.php         | 2 +-
 src/repository/api/ArcanistGitAPI.php                    | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/differential/ArcanistDifferentialDependencyGraph.php b/src/differential/ArcanistDifferentialDependencyGraph.php
index 64e2f9c71c20..fbc4e6594f0e 100644
--- a/src/differential/ArcanistDifferentialDependencyGraph.php
+++ b/src/differential/ArcanistDifferentialDependencyGraph.php
@@ -42,7 +42,8 @@ final class ArcanistDifferentialDependencyGraph extends AbstractDirectedGraph {
     $edges = array();
     foreach ($dependencies as $dependency) {
       $dependency_revision = $this->getCommitHashFromDict($dependency);
-      if ($repository_api->hasLocalCommit($dependency_revision)) {
+      if (phutil_nonempty_string($dependency_revision) &&
+          $repository_api->hasLocalCommit($dependency_revision)) {
         $edges[$dependency['phid']] = array();
         continue;
       }
diff --git a/src/lint/linter/ArcanistScriptAndRegexLinter.php b/src/lint/linter/ArcanistScriptAndRegexLinter.php
index 0c3d9d9a11ca..b9f6924ec997 100644
--- a/src/lint/linter/ArcanistScriptAndRegexLinter.php
+++ b/src/lint/linter/ArcanistScriptAndRegexLinter.php
@@ -338,7 +338,7 @@ final class ArcanistScriptAndRegexLinter extends ArcanistLinter {
     }
 
     $line = idx($match, 'line');
-    if (strlen($line)) {
+    if (phutil_nonempty_string($line) && strlen($line)) {
       $line = (int)$line;
       if (!$line) {
         $line = 1;
diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php
index 6c6d2ac42a19..13907d5634be 100644
--- a/src/repository/api/ArcanistGitAPI.php
+++ b/src/repository/api/ArcanistGitAPI.php
@@ -1143,7 +1143,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
 
   public function hasLocalCommit($commit) {
     try {
-      if (!$this->getCanonicalRevisionName($commit)) {
+      if (!phutil_nonempty_string($commit) ||
+          !$this->getCanonicalRevisionName($commit)) {
         return false;
       }
     } catch (CommandException $exception) {
-- 
2.37.0.rc0.161.g10f37bed90-goog