diff options
author | Byron Jones <bjones@mozilla.com> | 2013-10-28 17:09:07 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-10-28 17:09:07 +0100 |
commit | b7ebd27d636881700d442d3a2ff0cf6fa47ca639 (patch) | |
tree | 31502bcd8a197f083a4c3d376adf60210cb97264 /Bugzilla | |
parent | 4cd4a0fb1a5d66a6ea77b4653e76fae87bb0160f (diff) | |
download | bugzilla-b7ebd27d636881700d442d3a2ff0cf6fa47ca639.tar.gz bugzilla-b7ebd27d636881700d442d3a2ff0cf6fa47ca639.tar.xz |
Bug 931192: Add support for product aliases to search
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Search.pm | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index d66a6398f..bda57716a 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -132,6 +132,11 @@ use Time::HiRes qw(gettimeofday tv_interval); # Constants # ############# +# BMO - product aliases for searching +use constant PRODUCT_ALIASES => { + 'Boot2Gecko' => 'Firefox OS', +}; + # When doing searches, NULL datetimes are treated as this date. use constant EMPTY_DATETIME => '1970-01-01 00:00:00'; use constant EMPTY_DATE => '1970-01-01'; @@ -892,6 +897,24 @@ sub search_description { my ($self, $params) = @_; my $desc = $self->{'search_description'} ||= []; if ($params) { + + # BMO - product aliases + # display the new product name on the search results name to avoid a + # disparity between the search summary and the results. + if ($params->{field} eq 'product') { + my $aliased; + my @values = split(/,/, $params->{value}); + foreach my $value (@values) { + if (exists PRODUCT_ALIASES->{lc($value)}) { + $value = PRODUCT_ALIASES->{lc($value)}; + $aliased = 1; + } + } + if ($aliased) { + $params->{value} = join(',', @values); + } + } + push(@$desc, $params); } # Make sure that the description has actually been generated if @@ -2700,7 +2723,28 @@ sub _component_nonchanged { sub _product_nonchanged { my ($self, $args) = @_; - + + # BMO - product aliases + # swap out old product names for new ones + if (ref($args->{all_values})) { + my $aliased; + foreach my $value (@{ $args->{all_values} }) { + if (exists PRODUCT_ALIASES->{lc($value)}) { + $value = PRODUCT_ALIASES->{lc($value)}; + $aliased = 1; + } + } + if ($aliased) { + $args->{value} = join(',', @{ $args->{all_values} }); + $args->{quoted} = Bugzilla->dbh->quote($args->{value}); + } + } + elsif (exists PRODUCT_ALIASES->{lc($args->{value})}) { + $args->{value} = PRODUCT_ALIASES->{lc($args->{value})}; + $args->{all_values} = $args->{value}; + $args->{quoted} = Bugzilla->dbh->quote($args->{value}); + } + # Generate the restriction condition $args->{full_field} = "products.name"; $self->_do_operator_function($args); @@ -3367,6 +3411,12 @@ sub translate_old_column { return $column; } +# BMO - make product aliases lowercase +foreach my $name (keys %{ PRODUCT_ALIASES() }) { + PRODUCT_ALIASES->{lc($name)} = PRODUCT_ALIASES->{$name}; + delete PRODUCT_ALIASES->{$name}; +} + 1; __END__ |