mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
9bf5e17352
commit
9d512595c0
3 changed files with 42 additions and 1 deletions
|
@ -466,6 +466,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialBlockHeraldAction' => 'applications/differential/herald/DifferentialBlockHeraldAction.php',
|
'DifferentialBlockHeraldAction' => 'applications/differential/herald/DifferentialBlockHeraldAction.php',
|
||||||
'DifferentialBlockingReviewerDatasource' => 'applications/differential/typeahead/DifferentialBlockingReviewerDatasource.php',
|
'DifferentialBlockingReviewerDatasource' => 'applications/differential/typeahead/DifferentialBlockingReviewerDatasource.php',
|
||||||
'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php',
|
'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php',
|
||||||
|
'DifferentialBranchFieldTestCase' => 'applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php',
|
||||||
'DifferentialBuildableEngine' => 'applications/differential/harbormaster/DifferentialBuildableEngine.php',
|
'DifferentialBuildableEngine' => 'applications/differential/harbormaster/DifferentialBuildableEngine.php',
|
||||||
'DifferentialChangeDetailMailView' => 'applications/differential/mail/DifferentialChangeDetailMailView.php',
|
'DifferentialChangeDetailMailView' => 'applications/differential/mail/DifferentialChangeDetailMailView.php',
|
||||||
'DifferentialChangeHeraldFieldGroup' => 'applications/differential/herald/DifferentialChangeHeraldFieldGroup.php',
|
'DifferentialChangeHeraldFieldGroup' => 'applications/differential/herald/DifferentialChangeHeraldFieldGroup.php',
|
||||||
|
@ -6472,6 +6473,7 @@ phutil_register_library_map(array(
|
||||||
'DifferentialBlockHeraldAction' => 'HeraldAction',
|
'DifferentialBlockHeraldAction' => 'HeraldAction',
|
||||||
'DifferentialBlockingReviewerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
'DifferentialBlockingReviewerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||||
'DifferentialBranchField' => 'DifferentialCustomField',
|
'DifferentialBranchField' => 'DifferentialCustomField',
|
||||||
|
'DifferentialBranchFieldTestCase' => 'PhabricatorTestCase',
|
||||||
'DifferentialBuildableEngine' => 'HarbormasterBuildableEngine',
|
'DifferentialBuildableEngine' => 'HarbormasterBuildableEngine',
|
||||||
'DifferentialChangeDetailMailView' => 'DifferentialMailView',
|
'DifferentialChangeDetailMailView' => 'DifferentialMailView',
|
||||||
'DifferentialChangeHeraldFieldGroup' => 'HeraldFieldGroup',
|
'DifferentialChangeHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class DifferentialBranchField
|
||||||
return pht('%s (bookmark)', $bookmark);
|
return pht('%s (bookmark)', $bookmark);
|
||||||
} else if (strlen($branch)) {
|
} else if (strlen($branch)) {
|
||||||
$onto = $diff->loadTargetBranch();
|
$onto = $diff->loadTargetBranch();
|
||||||
if (strlen($onto) && ($onto !== $branch)) {
|
if (phutil_nonempty_string($onto) && ($onto !== $branch)) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s (branched from %s)',
|
'%s (branched from %s)',
|
||||||
$branch,
|
$branch,
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialBranchFieldTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
protected function getPhabricatorTestCaseConfiguration() {
|
||||||
|
return array(
|
||||||
|
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTestDiff() {
|
||||||
|
$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;
|
||||||
|
|
||||||
|
return DifferentialDiff::newFromRawChanges(
|
||||||
|
PhabricatorUser::getOmnipotentUser(),
|
||||||
|
$parser->parseDiff($raw_diff));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRenderDiffPropertyViewValue() {
|
||||||
|
$test_object = new DifferentialBranchField();
|
||||||
|
$diff = $this->getTestDiff();
|
||||||
|
$diff->setBranch('test');
|
||||||
|
$this->assertEqual('test',
|
||||||
|
$test_object->renderDiffPropertyViewValue($diff));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue