Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2874731
D25502.1736961548.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
D25502.1736961548.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 15, 17:19 (3 d, 12 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116098
Default Alt Text
D25502.1736961548.diff (1 KB)
Attached To
Mode
D25502: Make PhabricatorSearchIntField validate its input
Attached
Detach File
Event Timeline
Log In to Comment