Page MenuHomePhorge

D25502.1737248554.diff
No OneTemporary

D25502.1737248554.diff

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() {

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 19, 01:02 (5 h, 14 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116098
Default Alt Text
D25502.1737248554.diff (1 KB)

Event Timeline