From b21928599960ddad9bf0680dfc3d7a204e466e81 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 25 Nov 2015 08:21:24 -0800 Subject: [PATCH] Fix handling of implicit comment transaction in paste creation Summary: Fixes T9850. The `getComment()` test should be a `hasComment()` test, in order to discard empty comments. Also backport a couple of future fixes which can get you into trouble if you reconfigure forms in awkward ways. Test Plan: Created a new paste without a comment. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9850 Differential Revision: https://secure.phabricator.com/D14571 --- .../editfield/PhabricatorEditField.php | 16 ++++++++++++++-- .../PhabricatorApplicationTransactionEditor.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/applications/transactions/editfield/PhabricatorEditField.php b/src/applications/transactions/editfield/PhabricatorEditField.php index 60b48cc2b8..fcf66c3883 100644 --- a/src/applications/transactions/editfield/PhabricatorEditField.php +++ b/src/applications/transactions/editfield/PhabricatorEditField.php @@ -320,7 +320,13 @@ abstract class PhabricatorEditField extends Phobject { } protected function getValueExistsInSubmit(AphrontRequest $request, $key) { - return $this->getHTTPParameterType()->getExists($request, $key); + $type = $this->getHTTPParameterType(); + + if ($type) { + return $type->getExists($request, $key); + } + + return false; } protected function getValueFromSubmit(AphrontRequest $request, $key) { @@ -328,7 +334,13 @@ abstract class PhabricatorEditField extends Phobject { } protected function getDefaultValue() { - return $this->getHTTPParameterType()->getDefaultValue(); + $type = $this->getHTTPParameterType(); + + if ($type) { + return $type->getDefaultValue(); + } + + return null; } final public function getHTTPParameterType() { diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index d61b498edd..07c1b983fd 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1888,7 +1888,7 @@ abstract class PhabricatorApplicationTransactionEditor } foreach ($no_effect as $key => $xaction) { - if ($xaction->getComment()) { + if ($xaction->hasComment()) { $xaction->setTransactionType($type_comment); $xaction->setOldValue(null); $xaction->setNewValue(null);