]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1541898 - Allow to search on product/component pair
authorKohei Yoshino <kohei.yoshino@gmail.com>
Tue, 16 Jul 2019 00:24:40 +0000 (20:24 -0400)
committerGitHub <noreply@github.com>
Tue, 16 Jul 2019 00:24:40 +0000 (20:24 -0400)
Bugzilla/Search.pm

index e765c07a80d0451f6813f986c96b87fbe502860f..e856838198c1f9e4741847d0a1f30e6eeccd0180 100644 (file)
@@ -2874,13 +2874,37 @@ sub _assignee_last_login {
 
 sub _component_nonchanged {
   my ($self, $args) = @_;
+  my $dbh = Bugzilla->dbh;
+  my $product;
+
+  # Allow to search product/component pairs like "Core::General" with a simple
+  # operator. Since product/component names may include spaces, other operators
+  # like `anywords` won't work.
+  if ($args->{operator} =~ /^(:?(:?not)?equals)$/
+    && $args->{value} =~ /^(?:(.+)\s*::\s*)?(.+)$/)
+  {
+    $product = $1;
+    $args->{value}  = $args->{all_values} = $2;
+    $args->{quoted} = $dbh->quote($2);
+  }
 
   $args->{full_field} = "components.name";
   $self->_do_operator_function($args);
+
   my $term = $args->{term};
-  $args->{term}
-    = build_subselect("bugs.component_id", "components.id", "components",
-    $args->{term});
+
+  if ($product) {
+    # Pass the complete condition and negative option to make sure both product
+    # and component are included or excluded
+    $args->{term} = build_subselect('bugs.component_id', 'components.id',
+      'components JOIN products ON components.product_id = products.id',
+      'products.name = ' . $dbh->quote($product)
+        . ' AND components.name = ' . $args->{quoted},
+      $args->{operator} eq 'notequals');
+  } else {
+    $args->{term} = build_subselect('bugs.component_id', 'components.id',
+      'components', $term);
+  }
 }
 
 sub _product_nonchanged {