summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-02-02 05:38:16 +0100
committerByron Jones <glob@mozilla.com>2015-02-02 05:38:16 +0100
commit1ccc683d4d94ea70e763fbd4af9721cb4bca1c0d (patch)
tree90ec8af17c49c130b0e817d2ef00c8c667dcb764 /Bugzilla
parente62f3072492aa55e626325e8889365b23c25892f (diff)
downloadbugzilla-1ccc683d4d94ea70e763fbd4af9721cb4bca1c0d.tar.gz
bugzilla-1ccc683d4d94ea70e763fbd4af9721cb4bca1c0d.tar.xz
Bug 1123769: add a "rank" field to bugzilla to track priority
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm25
-rw-r--r--Bugzilla/Constants.pm2
-rw-r--r--Bugzilla/Field.pm2
3 files changed, 29 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 7d47e9bb5..e1f533274 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -179,6 +179,9 @@ sub VALIDATORS {
elsif ($field->type == FIELD_TYPE_BUG_ID) {
$validator = \&_check_bugid_field;
}
+ elsif ($field->type == FIELD_TYPE_INTEGER) {
+ $validator = \&_check_integer_field;
+ }
else {
$validator = \&_check_default_field;
}
@@ -2251,6 +2254,28 @@ sub _check_bugid_field {
return $checked_id;
}
+sub _check_integer_field {
+ my ($invocant, $value, $field) = @_;
+ $value = defined($value) ? trim($value) : '';
+
+ # BMO - allow empty values
+ if ($value eq '') {
+ return undef;
+ }
+
+ my $orig_value = $value;
+ if (!detaint_signed($value)) {
+ ThrowUserError("number_not_integer",
+ {field => $field, num => $orig_value});
+ }
+ elsif ($value > MAX_INT_32) {
+ ThrowUserError("number_too_large",
+ {field => $field, num => $orig_value, max_num => MAX_INT_32});
+ }
+
+ return $value;
+}
+
sub _check_relationship_loop {
# Generates a dependency tree for a given bug. Calls itself recursively
# to generate sub-trees for the bug's dependencies.
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 6e0a9c7d3..ad507c2ca 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -135,6 +135,7 @@ use Memoize;
FIELD_TYPE_BUG_ID
FIELD_TYPE_BUG_URLS
FIELD_TYPE_KEYWORDS
+ FIELD_TYPE_INTEGER
FIELD_TYPE_EXTENSION
FIELD_TYPE_HIGHEST_PLUS_ONE
@@ -437,6 +438,7 @@ use constant FIELD_TYPE_BUG_ID => 6;
use constant FIELD_TYPE_BUG_URLS => 7;
use constant FIELD_TYPE_KEYWORDS => 8;
use constant FIELD_TYPE_DATE => 9;
+use constant FIELD_TYPE_INTEGER => 10;
use constant FIELD_TYPE_EXTENSION => 99;
# Add new field types above this line, and change the below value in the
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 86811d9bc..84e2a1bfe 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -165,6 +165,8 @@ use constant SQL_DEFINITIONS => {
FIELD_TYPE_DATETIME, { TYPE => 'DATETIME' },
FIELD_TYPE_DATE, { TYPE => 'DATE' },
FIELD_TYPE_BUG_ID, { TYPE => 'INT3' },
+ # BMO : allow integer fields to be NULL
+ FIELD_TYPE_INTEGER, { TYPE => 'INT4' },
};
# Field definitions for the fields that ship with Bugzilla.