diff --git a/src/applications/search/field/PhabricatorSearchIntField.php b/src/applications/search/field/PhabricatorSearchIntField.php --- a/src/applications/search/field/PhabricatorSearchIntField.php +++ b/src/applications/search/field/PhabricatorSearchIntField.php @@ -8,7 +8,29 @@ } protected function getValueFromRequest(AphrontRequest $request, $key) { - return $request->getInt($key); + // Use getStr() to differentiate in validateControlValue() between 0 + // literally entered versus 0 returned by PHP casting a string to an int + return $request->getStr($key); + } + + public function getValueForQuery($value) { + return $this->validateControlValue($value); + } + + protected function validateControlValue($value) { + if ($value === null || $value === '') { + return $value; + } + // Handle negative number strings by stripping the minus + if (($value[0] === '-' || $value[0] === '\xe2\x88\x92')) { + $value = substr($value, 1); + } + if (ctype_digit((string)$value)) { + return $value; + } + $this->addError( + pht('Invalid'), + pht('Integer value for "%s" can not be parsed.', $this->getLabel())); } protected function newControl() {