From 3ab334af936d81725a36edb81441c56060924334 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 7 May 2011 10:42:40 -0700 Subject: [PATCH] Fix "reply" link in Differential Summary: Fixes the issue caused by rPa0af5b66437719dba6136579c051982ab275e6a0. Prior to that patch, isCommentInNewFile() returned $comment->getIsNewFile(). While this was often the wrong value, it came from the database and was the integer 1 if true. After the patch, the function returns 'true' as a boolean, which is passed to JS and then back to PHP, interpreted as an integer, and evaluates to 0. To avoid this issue in general, provide an isBool() method on AphrontRequest which interprets this correctly. I will also revert the revert of rPa0af5b66437719dba6136579c051982ab275e6a0 when I land this. Test Plan: Clicked "reply" on the right hand side of a diff, got a right-hand-side inline comment. Reviewed By: rm Reviewers: tuomaspelkonen, jungejason, aran, rm CC: simpkins, aran, epriestley, rm Differential Revision: 250 --- src/aphront/request/AphrontRequest.php | 14 ++++++++++++++ .../DifferentialInlineCommentEditController.php | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/aphront/request/AphrontRequest.php b/src/aphront/request/AphrontRequest.php index cdd46d5097..d491b68889 100644 --- a/src/aphront/request/AphrontRequest.php +++ b/src/aphront/request/AphrontRequest.php @@ -68,6 +68,20 @@ class AphrontRequest { } } + final public function getBool($name, $default = null) { + if (isset($this->requestData[$name])) { + if ($this->requestData[$name] === 'true') { + return true; + } else if ($this->requestData[$name] === 'false') { + return false; + } else { + return (bool)$this->requestData[$name]; + } + } else { + return $default; + } + } + final public function getStr($name, $default = null) { if (isset($this->requestData[$name])) { $str = (string)$this->requestData[$name]; diff --git a/src/applications/differential/controller/inlinecommentedit/DifferentialInlineCommentEditController.php b/src/applications/differential/controller/inlinecommentedit/DifferentialInlineCommentEditController.php index 2cf0561655..bd9969f1d8 100644 --- a/src/applications/differential/controller/inlinecommentedit/DifferentialInlineCommentEditController.php +++ b/src/applications/differential/controller/inlinecommentedit/DifferentialInlineCommentEditController.php @@ -28,8 +28,8 @@ class DifferentialInlineCommentEditController extends DifferentialController { $request = $this->getRequest(); $changeset = $request->getInt('changeset'); - $is_new = $request->getInt('is_new'); - $on_right = $request->getInt('on_right'); + $is_new = $request->getBool('is_new'); + $on_right = $request->getBool('on_right'); $number = $request->getInt('number'); $length = $request->getInt('length'); $text = $request->getStr('text');