summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Green <mail@simon.green>2015-07-29 12:02:50 +0200
committerSimon Green <mail@simon.green>2015-07-29 12:02:50 +0200
commit1457749bd9af96247c51fb5958d3f6d69399b33e (patch)
treee4bf29583b92400a04b510d2338ac6ebf8fe3125
parent6f9b176104ad62bf80b482b99ccf080c5ab5c3a5 (diff)
downloadbugzilla-1457749bd9af96247c51fb5958d3f6d69399b33e.tar.gz
bugzilla-1457749bd9af96247c51fb5958d3f6d69399b33e.tar.xz
Bug 166951 - Query for "Duplicate Of" (dupe_of)
r=dylan, a=simon
-rw-r--r--Bugzilla/Field.pm1
-rw-r--r--Bugzilla/Search.pm64
2 files changed, 65 insertions, 0 deletions
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 761f7b94e..d0e392243 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -268,6 +268,7 @@ use constant DEFAULT_FIELDS => (
{name => 'last_visit_ts', desc => 'Last Visit', buglist => 1,
type => FIELD_TYPE_DATETIME},
{name => 'comment_tag', desc => 'Comment Tag'},
+ {name => 'dupe_of', desc => 'Duplicate of'},
);
################
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 5cf36a761..c8677752e 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -287,6 +287,14 @@ use constant OPERATOR_FIELD_OVERRIDE => {
_default => \&_days_elapsed,
},
dependson => MULTI_SELECT_OVERRIDE,
+ dupe_of => {
+ %{ &MULTI_SELECT_OVERRIDE },
+ changedby => \&_dupe_of_changedby,
+ changedbefore => \&_dupe_of_changedbefore_after,
+ changedafter => \&_dupe_of_changedbefore_after,
+ changedfrom => \&_invalid_combination,
+ changedto => \&_invalid_combination,
+ },
keywords => MULTI_SELECT_OVERRIDE,
'flagtypes.name' => {
_non_changed => \&_flagtypes_nonchanged,
@@ -2516,6 +2524,48 @@ sub _user_nonchanged {
}
}
+# Changes to duplicates are stored in the longdesc table
+sub _dupe_of_changedby {
+ my ($self, $args) = @_;
+ my ($chart_id, $joins, $value) = @$args{qw(chart_id joins value)};
+
+ my $table = "longdescs_$chart_id";
+ push(@$joins, { table => 'longdescs', as => $table });
+ my $user_id = $self->_get_user_id($value);
+ $args->{term} = "$table.who = $user_id AND $table.type = " . CMT_DUPE_OF;
+
+ # If the user is not part of the insiders group, they cannot see
+ # private comments
+ if (!$self->_user->is_insider) {
+ $args->{term} .= " AND $table.isprivate = 0";
+ }
+}
+
+sub _dupe_of_changedbefore_after {
+ my ($self, $args) = @_;
+ my ($chart_id, $operator, $value, $joins) =
+ @$args{qw(chart_id operator value joins)};
+ my $dbh = Bugzilla->dbh;
+
+ my $sql_operator = ($operator =~ /before/) ? '<=' : '>=';
+ my $table = "longdescs_$chart_id";
+ my $sql_date = $dbh->quote(SqlifyDate($value));
+ my $join = {
+ table => 'longdescs',
+ as => $table,
+ extra => ["$table.bug_when $sql_operator $sql_date AND $table.type = " . CMT_DUPE_OF ],
+ };
+ push(@$joins, $join);
+ $args->{term} = "$table.bug_when IS NOT NULL";
+
+ # If the user is not part of the insiders group, they cannot see
+ # private comments
+ if (!$self->_user->is_insider) {
+ $args->{term} .= " AND $table.isprivate = 0";
+ }
+}
+
+
# XXX This duplicates having Commenter as a search field.
sub _long_desc_changedby {
my ($self, $args) = @_;
@@ -2972,6 +3022,11 @@ sub _multiselect_table {
$args->{full_field} = $field;
return "dependencies";
}
+ elsif ($field eq 'dupe_of') {
+ $args->{_select_field} = 'dupe';
+ $args->{full_field} = 'dupe_of';
+ return "duplicates";
+ }
elsif ($field eq 'longdesc') {
$args->{_extra_where} = " AND isprivate = 0"
if !$self->_user->is_insider;
@@ -3072,6 +3127,15 @@ sub _multiselect_isempty {
};
return "dependencies_$chart_id.$to IS $not NULL";
}
+ elsif ($field eq 'dupe_of') {
+ push @$joins, {
+ table => 'duplicates',
+ as => "duplicates_$chart_id",
+ from => 'bug_id',
+ to => 'dupe',
+ };
+ return "duplicates_$chart_id.dupe IS $not NULL";
+ }
elsif ($field eq 'longdesc') {
my @extra = ( "longdescs_$chart_id.type != " . CMT_HAS_DUPE );
push @extra, "longdescs_$chart_id.isprivate = 0"