@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 PHP 8.1 DifferentialBranchField getBranchDescription strlen(null) error

Summary:
Fix PHP 8.1 strlen(null) error in DifferentialBranchField getBranchDescription()

Fixes T15531

Test Plan:
Simply viewing a diff (eg https://my.phorge.site/D1234) on a PHP 8.1 server generated the error fixed by this diff.

Also created a unit test.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15531

Differential Revision: https://we.phorge.it/D25335

+42 -1
+2
src/__phutil_library_map__.php
··· 466 466 'DifferentialBlockHeraldAction' => 'applications/differential/herald/DifferentialBlockHeraldAction.php', 467 467 'DifferentialBlockingReviewerDatasource' => 'applications/differential/typeahead/DifferentialBlockingReviewerDatasource.php', 468 468 'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php', 469 + 'DifferentialBranchFieldTestCase' => 'applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php', 469 470 'DifferentialBuildableEngine' => 'applications/differential/harbormaster/DifferentialBuildableEngine.php', 470 471 'DifferentialChangeDetailMailView' => 'applications/differential/mail/DifferentialChangeDetailMailView.php', 471 472 'DifferentialChangeHeraldFieldGroup' => 'applications/differential/herald/DifferentialChangeHeraldFieldGroup.php', ··· 6472 6473 'DifferentialBlockHeraldAction' => 'HeraldAction', 6473 6474 'DifferentialBlockingReviewerDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 6474 6475 'DifferentialBranchField' => 'DifferentialCustomField', 6476 + 'DifferentialBranchFieldTestCase' => 'PhabricatorTestCase', 6475 6477 'DifferentialBuildableEngine' => 'HarbormasterBuildableEngine', 6476 6478 'DifferentialChangeDetailMailView' => 'DifferentialMailView', 6477 6479 'DifferentialChangeHeraldFieldGroup' => 'HeraldFieldGroup',
+1 -1
src/applications/differential/customfield/DifferentialBranchField.php
··· 45 45 return pht('%s (bookmark)', $bookmark); 46 46 } else if (strlen($branch)) { 47 47 $onto = $diff->loadTargetBranch(); 48 - if (strlen($onto) && ($onto !== $branch)) { 48 + if (phutil_nonempty_string($onto) && ($onto !== $branch)) { 49 49 return pht( 50 50 '%s (branched from %s)', 51 51 $branch,
+39
src/applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php
··· 1 + <?php 2 + 3 + final class DifferentialBranchFieldTestCase extends PhabricatorTestCase { 4 + 5 + protected function getPhabricatorTestCaseConfiguration() { 6 + return array( 7 + self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, 8 + ); 9 + } 10 + 11 + private function getTestDiff() { 12 + $parser = new ArcanistDiffParser(); 13 + $raw_diff = <<<EODIFF 14 + diff --git a/src b/src 15 + index 123457..bb216b1 100644 16 + --- a/src 17 + +++ b/src 18 + @@ -1,5 +1,5 @@ 19 + Line a 20 + -Line b 21 + +Line 2 22 + Line c 23 + Line d 24 + Line e 25 + EODIFF; 26 + 27 + return DifferentialDiff::newFromRawChanges( 28 + PhabricatorUser::getOmnipotentUser(), 29 + $parser->parseDiff($raw_diff)); 30 + } 31 + 32 + public function testRenderDiffPropertyViewValue() { 33 + $test_object = new DifferentialBranchField(); 34 + $diff = $this->getTestDiff(); 35 + $diff->setBranch('test'); 36 + $this->assertEqual('test', 37 + $test_object->renderDiffPropertyViewValue($diff)); 38 + } 39 + }