Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2693720
D25334.1734769676.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
4 KB
Referenced Files
None
Subscribers
None
D25334.1734769676.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -713,6 +713,7 @@
'DifferentialTabReplacementTestCase' => 'applications/differential/parser/__tests__/DifferentialTabReplacementTestCase.php',
'DifferentialTagsCommitMessageField' => 'applications/differential/field/DifferentialTagsCommitMessageField.php',
'DifferentialTasksCommitMessageField' => 'applications/differential/field/DifferentialTasksCommitMessageField.php',
+ 'DifferentialTestCommitMessageField' => 'applications/differential/field/DifferentialTestCommitMessageField.php',
'DifferentialTestPlanCommitMessageField' => 'applications/differential/field/DifferentialTestPlanCommitMessageField.php',
'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php',
'DifferentialTitleCommitMessageField' => 'applications/differential/field/DifferentialTitleCommitMessageField.php',
@@ -6756,6 +6757,7 @@
'DifferentialTabReplacementTestCase' => 'PhabricatorTestCase',
'DifferentialTagsCommitMessageField' => 'DifferentialCommitMessageField',
'DifferentialTasksCommitMessageField' => 'DifferentialCommitMessageField',
+ 'DifferentialTestCommitMessageField' => 'DifferentialCommitMessageField',
'DifferentialTestPlanCommitMessageField' => 'DifferentialCommitMessageField',
'DifferentialTestPlanField' => 'DifferentialCoreCustomField',
'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField',
diff --git a/src/applications/differential/field/DifferentialCommitMessageField.php b/src/applications/differential/field/DifferentialCommitMessageField.php
--- a/src/applications/differential/field/DifferentialCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialCommitMessageField.php
@@ -60,7 +60,7 @@
}
public function renderFieldValue($value) {
- if (!strlen($value)) {
+ if (!phutil_nonempty_string($value)) {
return null;
}
diff --git a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
--- a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
+++ b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
@@ -72,7 +72,7 @@
}
public function renderFieldValue($value) {
- if (!strlen($value)) {
+ if (!phutil_nonempty_string($value)) {
return null;
}
diff --git a/src/applications/differential/field/DifferentialTestCommitMessageField.php b/src/applications/differential/field/DifferentialTestCommitMessageField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/field/DifferentialTestCommitMessageField.php
@@ -0,0 +1,10 @@
+<?php
+
+/**
+ * This class should only be used for unit tests
+ */
+final class DifferentialTestCommitMessageField
+ extends DifferentialCommitMessageField {
+ public function getFieldName() { return 'Test'; }
+ public function getFieldOrder() { return 1; }
+}
diff --git a/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php b/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
--- a/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
+++ b/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
@@ -28,4 +28,21 @@
unset($env);
}
+ public function testRenderFieldValue() {
+ $test_object = new DifferentialTestCommitMessageField();
+ $this->assertEqual('foo', $test_object->renderFieldValue('foo'),
+ 'Normal strings should be rendered unaltered');
+
+ $this->assertEqual(null, $test_object->renderFieldValue(''),
+ 'Empty strings should be returned as null');
+
+ $this->assertEqual(null, $test_object->renderFieldValue(null),
+ 'null values strings should be returned as null');
+
+ $test_object = new DifferentialRevisionIDCommitMessageField();
+ $expected = 'http://phabricator.example.com/D123';
+ $this->assertEqual($expected, $test_object->renderFieldValue('123'));
+ $this->assertEqual(null, $test_object->renderFieldValue(null));
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 08:27 (2 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1024192
Default Alt Text
D25334.1734769676.diff (4 KB)
Attached To
Mode
D25334: Fix DifferentialCommitMessageField renderFieldValue PHP 8.1 strlen(null) error
Attached
Detach File
Event Timeline
Log In to Comment