summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm7
-rw-r--r--Bugzilla/Field.pm31
-rw-r--r--Bugzilla/Flag.pm3
-rw-r--r--Bugzilla/Search.pm5
4 files changed, 38 insertions, 8 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index dfa419316..3a80f4095 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -40,6 +40,7 @@ use Bugzilla::Attachment;
use Bugzilla::BugMail;
use Bugzilla::Config;
use Bugzilla::Constants;
+use Bugzilla::Field;
use Bugzilla::Flag;
use Bugzilla::FlagType;
use Bugzilla::User;
@@ -956,7 +957,7 @@ sub LogActivityEntry {
}
trick_taint($addstr);
trick_taint($removestr);
- my $fieldid = &::GetFieldID($col);
+ my $fieldid = get_field_id($col);
$dbh->do("INSERT INTO bugs_activity
(bug_id, who, bug_when, fieldid, removed, added)
VALUES (?, ?, ?, ?, ?, ?)",
@@ -1106,7 +1107,7 @@ sub CheckIfVotedConfirmed {
my $ret = 0;
if ($votes >= $votestoconfirm && !$everconfirmed) {
if ($status eq 'UNCONFIRMED') {
- my $fieldid = &::GetFieldID("bug_status");
+ my $fieldid = get_field_id("bug_status");
$dbh->do("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1, " .
"delta_ts = ? WHERE bug_id = ?",
undef, ($timestamp, $id));
@@ -1120,7 +1121,7 @@ sub CheckIfVotedConfirmed {
"WHERE bug_id = ?", undef, ($timestamp, $id));
}
- my $fieldid = &::GetFieldID("everconfirmed");
+ my $fieldid = get_field_id("everconfirmed");
$dbh->do("INSERT INTO bugs_activity " .
"(bug_id, who, bug_when, fieldid, removed, added) " .
"VALUES (?, ?, ?, ?, ?, ?)",
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 26265ac3d..09c4731ac 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -20,7 +20,8 @@ package Bugzilla::Field;
use strict;
use base qw(Exporter);
-@Bugzilla::Field::EXPORT = qw(check_form_field check_form_field_defined);
+@Bugzilla::Field::EXPORT = qw(check_form_field check_form_field_defined
+ get_field_id);
use Bugzilla::Util;
use Bugzilla::Error;
@@ -52,6 +53,22 @@ sub check_form_field_defined {
}
}
+sub get_field_id {
+ my ($name) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ trick_taint($name);
+ my $id = $dbh->selectrow_array('SELECT fieldid FROM fielddefs
+ WHERE name = ?', undef, $name);
+
+ ThrowCodeError('invalid_field_name', {field => $name}) unless $id;
+ return $id
+}
+
+1;
+
+__END__
+
=head1 NAME
Bugzilla::Field - Useful routines for fields manipulation
@@ -63,7 +80,7 @@ Bugzilla::Field - Useful routines for fields manipulation
# Validation Routines
check_form_field($cgi, $fieldname, \@legal_values);
check_form_field_defined($cgi, $fieldname);
-
+ $fieldid = get_field_id($fieldname);
=head1 DESCRIPTION
@@ -101,4 +118,14 @@ Params: $cgi - a CGI object
Returns: nothing
+=item C<get_field_id($fieldname)>
+
+Description: Returns the ID of the specified field name and throws
+ an error if this field does not exist.
+
+Params: $fieldname - a field name
+
+Returns: the corresponding field ID or an error if the field name
+ does not exist.
+
=back
diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm
index 89dda08a5..34ded7dd2 100644
--- a/Bugzilla/Flag.pm
+++ b/Bugzilla/Flag.pm
@@ -72,6 +72,7 @@ use Bugzilla::Error;
use Bugzilla::Attachment;
use Bugzilla::BugMail;
use Bugzilla::Constants;
+use Bugzilla::Field;
# Note that this line doesn't actually import these variables for some reason,
# so I have to use them as $::template and $::vars in the package code.
@@ -500,7 +501,7 @@ sub update_activity {
if ($removed ne $added) {
my $sql_removed = &::SqlQuote($removed);
my $sql_added = &::SqlQuote($added);
- my $field_id = &::GetFieldID('flagtypes.name');
+ my $field_id = get_field_id('flagtypes.name');
$dbh->do("INSERT INTO bugs_activity
(bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bug_id, $attach_id, $::userid, $timestamp,
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 42f6da749..55113f641 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -44,6 +44,7 @@ use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::Group;
use Bugzilla::User;
+use Bugzilla::Field;
use Date::Format;
use Date::Parse;
@@ -312,7 +313,7 @@ sub init {
push(@l, "bugs.creation_ts <= $sql_chto") if($sql_chto);
$bug_creation_clause = "(" . join(' AND ', @l) . ")";
} else {
- push(@list, "\nactcheck.fieldid = " . &::GetFieldID($f));
+ push(@list, "\nactcheck.fieldid = " . get_field_id($f));
}
}
@@ -998,7 +999,7 @@ sub init {
}
my $cutoff = "NOW() - " .
$dbh->sql_interval("$quantity $unitinterval");
- my $assigned_fieldid = &::GetFieldID('assigned_to');
+ my $assigned_fieldid = get_field_id('assigned_to');
push(@supptables, "LEFT JOIN longdescs AS comment_$table " .
"ON comment_$table.who = bugs.assigned_to " .
"AND comment_$table.bug_id = bugs.bug_id " .