summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm2
-rw-r--r--Bugzilla/BugMail.pm4
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Field.pm78
-rw-r--r--Bugzilla/Search.pm2
5 files changed, 29 insertions, 59 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 64da19af4..ba69932e9 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -876,7 +876,7 @@ sub GetBugActivity {
FROM bugs_activity
$suppjoins
LEFT JOIN fielddefs
- ON bugs_activity.fieldid = fielddefs.fieldid
+ ON bugs_activity.fieldid = fielddefs.id
INNER JOIN profiles
ON profiles.userid = bugs_activity.who
WHERE bugs_activity.bug_id = ?
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 3597b3f46..1b2fb5429 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -224,7 +224,7 @@ sub ProcessOneBug {
bugs_activity.added, bugs_activity.attach_id, fielddefs.name
FROM bugs_activity
INNER JOIN fielddefs
- ON fielddefs.fieldid = bugs_activity.fieldid
+ ON fielddefs.id = bugs_activity.fieldid
INNER JOIN profiles
ON profiles.userid = bugs_activity.who
WHERE bugs_activity.bug_id = ?
@@ -277,7 +277,7 @@ sub ProcessOneBug {
INNER JOIN dependencies
ON bugs_activity.bug_id = dependencies.dependson
INNER JOIN fielddefs
- ON fielddefs.fieldid = bugs_activity.fieldid
+ ON fielddefs.id = bugs_activity.fieldid
WHERE dependencies.blocked = ?
AND (fielddefs.name = 'bug_status'
OR fielddefs.name = 'resolution')
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 94e457dd0..5396a3d20 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -451,7 +451,7 @@ use constant ABSTRACT_SCHEMA => {
fielddefs => {
FIELDS => [
- fieldid => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
+ id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
type => {TYPE => 'INT2', NOTNULL => 1,
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index e964141d4..e870ec01d 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -38,18 +38,18 @@ Bugzilla::Field - a particular piece of information about bugs
use Bugzilla::Field;
# Display information about non-obsolete custom fields.
- # Bugzilla->get_fields() is a wrapper around Bugzilla::Field::match(),
+ # Bugzilla->get_fields() is a wrapper around Bugzilla::Field->match(),
# so both methods take the same arguments.
- print Dumper(Bugzilla::Field::match({ obsolete => 1, custom => 1 }));
+ print Dumper(Bugzilla::Field->match({ obsolete => 1, custom => 1 }));
# Create a custom field.
my $field = Bugzilla::Field::create("hilarity", "Hilarity");
- print "$field->{description} is a custom field\n";
+ print $field->description . " is a custom field\n";
# Instantiate a Field object for an existing field.
- my $field = new Bugzilla::Field('qacontact_accessible');
- if ($field->{obsolete}) {
- print "$field->{description} is obsolete\n";
+ my $field = new Bugzilla::Field({name => 'qacontact_accessible'});
+ if ($field->obsolete) {
+ print $field->description . " is obsolete\n";
}
# Validation Routines
@@ -63,21 +63,28 @@ of information that Bugzilla stores about bugs.
This package also provides functions for dealing with CGI form fields.
+C<Bugzilla::Field> is an implementation of L<Bugzilla::Object>, and
+so provides all of the methods available in L<Bugzilla::Object>,
+in addition to what is documented here.
+
=cut
package Bugzilla::Field;
use strict;
-use base qw(Exporter);
+use base qw(Exporter Bugzilla::Object);
@Bugzilla::Field::EXPORT = qw(check_field get_field_id get_legal_field_values);
use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::Error;
+use constant DB_TABLE => 'fielddefs';
+use constant LIST_ORDER => 'sortkey, name';
+
use constant DB_COLUMNS => (
- 'fieldid AS id',
+ 'id',
'name',
'description',
'type',
@@ -86,52 +93,18 @@ use constant DB_COLUMNS => (
'enter_bug',
);
-our $columns = join(", ", DB_COLUMNS);
-
-sub new {
- my $invocant = shift;
- my $name = shift;
- my $self = shift || Bugzilla->dbh->selectrow_hashref(
- "SELECT $columns FROM fielddefs WHERE name = ?",
- undef,
- $name
- );
- bless($self, $invocant);
- return $self;
-}
-
=pod
=head2 Instance Properties
=over
-=item C<id>
-
-the unique identifier for the field;
-
-=back
-
-=cut
-
-sub id { return $_[0]->{id} }
-
-=over
-
=item C<name>
the name of the field in the database; begins with "cf_" if field
is a custom field, but test the value of the boolean "custom" property
to determine if a given field is a custom field;
-=back
-
-=cut
-
-sub name { return $_[0]->{name} }
-
-=over
-
=item C<description>
a short string describing the field; displayed to Bugzilla users
@@ -242,7 +215,7 @@ sub create {
);
$sth->execute($name, $desc, $sortkey, $type, $custom);
- return new Bugzilla::Field($name);
+ return new Bugzilla::Field({name => $name});
}
@@ -262,14 +235,14 @@ Params: C<$criteria> - hash reference - the criteria to match against.
Note: Bugzilla->get_fields() and Bugzilla->custom_field_names
wrap this method for most callers.
-Returns: a list of field objects.
+Returns: A reference to an array of C<Bugzilla::Field> objects.
=back
=cut
sub match {
- my ($criteria) = @_;
+ my ($class, $criteria) = @_;
my @terms;
if (defined $criteria->{name}) {
@@ -286,13 +259,10 @@ sub match {
}
my $where = (scalar(@terms) > 0) ? "WHERE " . join(" AND ", @terms) : "";
- my $records = Bugzilla->dbh->selectall_arrayref(
- "SELECT $columns FROM fielddefs $where ORDER BY sortkey",
- { Slice => {}}
- );
- # Generate a array of field objects from the array of field records.
- my @fields = map( new Bugzilla::Field(undef, $_), @$records );
- return @fields;
+ my $ids = Bugzilla->dbh->selectcol_arrayref(
+ "SELECT id FROM fielddefs $where", {Slice => {}});
+
+ return $class->new_from_list($ids);
}
=pod
@@ -371,7 +341,7 @@ sub check_field {
return 0 if $no_warn; # We don't want an error to be thrown; return.
trick_taint($name);
- my $field = new Bugzilla::Field($name);
+ my $field = new Bugzilla::Field({ name => $name });
my $field_desc = $field ? $field->description : $name;
ThrowCodeError('illegal_field', { field => $field_desc });
}
@@ -401,7 +371,7 @@ sub get_field_id {
my $dbh = Bugzilla->dbh;
trick_taint($name);
- my $id = $dbh->selectrow_array('SELECT fieldid FROM fielddefs
+ my $id = $dbh->selectrow_array('SELECT id FROM fielddefs
WHERE name = ?', undef, $name);
ThrowCodeError('invalid_field_name', {field => $name}) unless $id;
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index bdf764f36..673deaa30 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -1276,7 +1276,7 @@ sub init {
# get a list of field names to verify the user-submitted chart fields against
%chartfields = @{$dbh->selectcol_arrayref(
- q{SELECT name, fieldid FROM fielddefs}, { Columns=>[1,2] })};
+ q{SELECT name, id FROM fielddefs}, { Columns=>[1,2] })};
$row = 0;
for ($chart=-1 ;