@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

sten 83105915 4b3c3848

+42 -6
+1 -1
src/__phutil_library_map__.php
··· 6565 6565 'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField', 6566 6566 'DifferentialDiffSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 6567 6567 'DifferentialDiffSearchEngine' => 'PhabricatorApplicationSearchEngine', 6568 - 'DifferentialDiffTestCase' => 'PhutilTestCase', 6568 + 'DifferentialDiffTestCase' => 'PhabricatorTestCase', 6569 6569 'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction', 6570 6570 'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6571 6571 'DifferentialDiffViewController' => 'DifferentialController',
+4 -4
src/applications/differential/storage/DifferentialDiff.php
··· 780 780 $refs = array(); 781 781 782 782 $branch = $this->getBranch(); 783 - if (strlen($branch)) { 783 + if (phutil_nonempty_string($branch)) { 784 784 $refs[] = array( 785 785 'type' => 'branch', 786 786 'name' => $branch, ··· 788 788 } 789 789 790 790 $onto = $this->loadTargetBranch(); 791 - if (strlen($onto)) { 791 + if (phutil_nonempty_string($onto)) { 792 792 $refs[] = array( 793 793 'type' => 'onto', 794 794 'name' => $onto, ··· 796 796 } 797 797 798 798 $base = $this->getSourceControlBaseRevision(); 799 - if (strlen($base)) { 799 + if ($base !== null && strlen($base)) { 800 800 $refs[] = array( 801 801 'type' => 'base', 802 802 'identifier' => $base, ··· 804 804 } 805 805 806 806 $bookmark = $this->getBookmark(); 807 - if (strlen($bookmark)) { 807 + if (phutil_nonempty_string($bookmark)) { 808 808 $refs[] = array( 809 809 'type' => 'bookmark', 810 810 'name' => $bookmark,
+37 -1
src/applications/differential/storage/__tests__/DifferentialDiffTestCase.php
··· 1 1 <?php 2 2 3 - final class DifferentialDiffTestCase extends PhutilTestCase { 3 + final class DifferentialDiffTestCase extends PhabricatorTestCase { 4 + 5 + protected function getPhabricatorTestCaseConfiguration() { 6 + return array( 7 + self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, 8 + ); 9 + } 4 10 5 11 public function testDetectCopiedCode() { 6 12 $copies = $this->detectCopiesIn('lint_engine.diff'); ··· 73 79 $this->assertTrue(true); 74 80 } 75 81 82 + public function testGetFieldValuesForConduit() { 83 + 84 + $parser = new ArcanistDiffParser(); 85 + $raw_diff = <<<EODIFF 86 + diff --git a/src b/src 87 + index 123457..bb216b1 100644 88 + --- a/src 89 + +++ b/src 90 + @@ -1,5 +1,5 @@ 91 + Line a 92 + -Line b 93 + +Line 2 94 + Line c 95 + Line d 96 + Line e 97 + EODIFF; 98 + 99 + $diff = DifferentialDiff::newFromRawChanges( 100 + PhabricatorUser::getOmnipotentUser(), 101 + $parser->parseDiff($raw_diff)); 102 + $this->assertTrue(true); 103 + 104 + $field_values = $diff->getFieldValuesForConduit(); 105 + $this->assertTrue(is_array($field_values)); 106 + foreach (['revisionPHID', 'authorPHID', 'repositoryPHID', 'refs'] 107 + as $key) { 108 + $this->assertTrue(array_key_exists($key, $field_values)); 109 + } 110 + 111 + } 76 112 77 113 }