From aab0fb0e74185542036614a22b3bef83ddb915e5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 5 Mar 2013 13:23:56 -0800 Subject: [PATCH] Fix HTTP 400 / 500 errors in Pholio Summary: Ref T2650. Possible fix for that issue. - "Passthru" got renamed to "passthrough" but a site was missed. - Don't try to post an empty comment if the text is empty but we have inlines; this avoids popping a "you can't post an empty comment" error. Test Plan: Made an empty comment with an inline in Pholio. Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T2650 Differential Revision: https://secure.phabricator.com/D5240 --- src/aphront/AphrontRequest.php | 2 +- .../PholioMockCommentController.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/aphront/AphrontRequest.php b/src/aphront/AphrontRequest.php index 42c80f5f6f..4da973156b 100644 --- a/src/aphront/AphrontRequest.php +++ b/src/aphront/AphrontRequest.php @@ -372,7 +372,7 @@ final class AphrontRequest { * @return dict Original request parameters. */ public function getPassthroughRequestParameters() { - return self::flattenData($this->getPassthruRequestData()); + return self::flattenData($this->getPassthroughRequestData()); } /** diff --git a/src/applications/pholio/controller/PholioMockCommentController.php b/src/applications/pholio/controller/PholioMockCommentController.php index e711a05877..af0b1b6e73 100644 --- a/src/applications/pholio/controller/PholioMockCommentController.php +++ b/src/applications/pholio/controller/PholioMockCommentController.php @@ -44,21 +44,24 @@ final class PholioMockCommentController extends PholioController { )); $xactions = array(); - $xactions[] = id(new PholioTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) - ->attachComment( - id(new PholioTransactionComment()) - ->setContent($comment)); - $inlineComments = id(new PholioTransactionComment())->loadAllWhere( + $inline_comments = id(new PholioTransactionComment())->loadAllWhere( 'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)', $user->getPHID(), mpull($mock->getImages(), 'getID')); - foreach ($inlineComments as $inlineComment) { + if (!$inline_comments || strlen($comment)) { + $xactions[] = id(new PholioTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) + ->attachComment( + id(new PholioTransactionComment()) + ->setContent($comment)); + } + + foreach ($inline_comments as $inline_comment) { $xactions[] = id(new PholioTransaction()) ->setTransactionType(PholioTransactionType::TYPE_INLINE) - ->attachComment($inlineComment); + ->attachComment($inline_comment); } $editor = id(new PholioMockEditor())