mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Fix DifferentialDiff getFieldValuesForConduit PHP 8.1 strlen(null) errors
Summary: Fix DifferentialDiff getFieldValuesForConduit PHP 8.1 strlen(null) errors by replacing the strlen() calls with phutil_nonempty_string(). Also needed to update DifferentialDiffTestCase.php to being a PhabricatorTestCase, as it was throwing an exception prior to any code changes - ``` EXCEPTION (Exception): Trying to read configuration "policy.locked" before configuration has been initialized. ``` Fixes T15529 Test Plan: arc diff Reviewers: O1 Blessed Committers, valerio.bozzolan, avivey Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15529 Differential Revision: https://we.phorge.it/D25333
This commit is contained in:
parent
4b3c384856
commit
8310591523
3 changed files with 42 additions and 6 deletions
|
@ -6565,7 +6565,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
'DifferentialDiffSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
'DifferentialDiffSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
|
||||||
'DifferentialDiffSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DifferentialDiffSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'DifferentialDiffTestCase' => 'PhutilTestCase',
|
'DifferentialDiffTestCase' => 'PhabricatorTestCase',
|
||||||
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||||
'DifferentialDiffViewController' => 'DifferentialController',
|
'DifferentialDiffViewController' => 'DifferentialController',
|
||||||
|
|
|
@ -780,7 +780,7 @@ final class DifferentialDiff
|
||||||
$refs = array();
|
$refs = array();
|
||||||
|
|
||||||
$branch = $this->getBranch();
|
$branch = $this->getBranch();
|
||||||
if (strlen($branch)) {
|
if (phutil_nonempty_string($branch)) {
|
||||||
$refs[] = array(
|
$refs[] = array(
|
||||||
'type' => 'branch',
|
'type' => 'branch',
|
||||||
'name' => $branch,
|
'name' => $branch,
|
||||||
|
@ -788,7 +788,7 @@ final class DifferentialDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
$onto = $this->loadTargetBranch();
|
$onto = $this->loadTargetBranch();
|
||||||
if (strlen($onto)) {
|
if (phutil_nonempty_string($onto)) {
|
||||||
$refs[] = array(
|
$refs[] = array(
|
||||||
'type' => 'onto',
|
'type' => 'onto',
|
||||||
'name' => $onto,
|
'name' => $onto,
|
||||||
|
@ -796,7 +796,7 @@ final class DifferentialDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
$base = $this->getSourceControlBaseRevision();
|
$base = $this->getSourceControlBaseRevision();
|
||||||
if (strlen($base)) {
|
if ($base !== null && strlen($base)) {
|
||||||
$refs[] = array(
|
$refs[] = array(
|
||||||
'type' => 'base',
|
'type' => 'base',
|
||||||
'identifier' => $base,
|
'identifier' => $base,
|
||||||
|
@ -804,7 +804,7 @@ final class DifferentialDiff
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookmark = $this->getBookmark();
|
$bookmark = $this->getBookmark();
|
||||||
if (strlen($bookmark)) {
|
if (phutil_nonempty_string($bookmark)) {
|
||||||
$refs[] = array(
|
$refs[] = array(
|
||||||
'type' => 'bookmark',
|
'type' => 'bookmark',
|
||||||
'name' => $bookmark,
|
'name' => $bookmark,
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DifferentialDiffTestCase extends PhutilTestCase {
|
final class DifferentialDiffTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
protected function getPhabricatorTestCaseConfiguration() {
|
||||||
|
return array(
|
||||||
|
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDetectCopiedCode() {
|
public function testDetectCopiedCode() {
|
||||||
$copies = $this->detectCopiesIn('lint_engine.diff');
|
$copies = $this->detectCopiesIn('lint_engine.diff');
|
||||||
|
@ -73,5 +79,35 @@ EODIFF;
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetFieldValuesForConduit() {
|
||||||
|
|
||||||
|
$parser = new ArcanistDiffParser();
|
||||||
|
$raw_diff = <<<EODIFF
|
||||||
|
diff --git a/src b/src
|
||||||
|
index 123457..bb216b1 100644
|
||||||
|
--- a/src
|
||||||
|
+++ b/src
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
Line a
|
||||||
|
-Line b
|
||||||
|
+Line 2
|
||||||
|
Line c
|
||||||
|
Line d
|
||||||
|
Line e
|
||||||
|
EODIFF;
|
||||||
|
|
||||||
|
$diff = DifferentialDiff::newFromRawChanges(
|
||||||
|
PhabricatorUser::getOmnipotentUser(),
|
||||||
|
$parser->parseDiff($raw_diff));
|
||||||
|
$this->assertTrue(true);
|
||||||
|
|
||||||
|
$field_values = $diff->getFieldValuesForConduit();
|
||||||
|
$this->assertTrue(is_array($field_values));
|
||||||
|
foreach (['revisionPHID', 'authorPHID', 'repositoryPHID', 'refs']
|
||||||
|
as $key) {
|
||||||
|
$this->assertTrue(array_key_exists($key, $field_values));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue