]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1531968 - Allow to search bugs by Firefox merge dates
authorKohei Yoshino <kohei.yoshino@gmail.com>
Wed, 26 Jun 2019 21:25:20 +0000 (17:25 -0400)
committerGitHub <noreply@github.com>
Wed, 26 Jun 2019 21:25:20 +0000 (17:25 -0400)
Bugzilla/Hook.pm
Bugzilla/Search.pm
extensions/BMO/Extension.pm
extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl

index 888f8884ee22ee03b5a372d330d0b16065a68f45..b4f061ef9881e133be92b71bca59d9149c472c81 100644 (file)
@@ -597,6 +597,22 @@ Params:
 
 =back
 
+=head2 search_timestamp_translate
+
+This happens in L<Bugzilla::Search/_timestamp_translate> and allows you to
+support pronouns for specific dates, such as a product release date. Check the
+`value` argument and replace it with actual date where needed.
+
+Params:
+
+=over
+
+=item C<search> - The L<Bugzilla::Search> object.
+
+=item C<args> - The original arguments including C<value>.
+
+=back
+
 =head2 search_operator_field_override
 
 This allows you to modify L<Bugzilla::Search/OPERATOR_FIELD_OVERRIDE>,
index b9f1ea283357559eb5a4dfdc43ae9c733fbe8b36..e765c07a80d0451f6813f986c96b87fbe502860f 100644 (file)
@@ -2207,6 +2207,10 @@ sub _timestamp_translate {
   my $value = $args->{value};
   my $dbh   = Bugzilla->dbh;
 
+  # Allow to support custom date pronouns
+  Bugzilla::Hook::process('search_timestamp_translate',
+    {search => $self, args => $args});
+
   return if $value !~ /^(?:[\+\-]?\d+[hdwmy]s?|now)$/i;
 
   $value = SqlifyDate($value);
index dbab0e5c66b68e0e02e088d6cdb00689aebbaf0c..aeeb5d07ada3b9a8837ce9221552aa4bc29754eb 100644 (file)
@@ -2732,19 +2732,35 @@ sub search_params_to_data_structure {
     # Replace keys
     if ($key =~ $flag_re) {
       my ($canonical, $alias) = _get_search_param_name($1, $2, $3);
-      ThrowUserError('product_versions_unavailable') unless $canonical;
+      ThrowUserError('product_version_pronouns_unavailable') unless $canonical;
       $params->{$canonical} = delete $params->{$key};
     }
 
     # Replace values (custom search)
     if ($params->{$key} =~ $flag_re) {
       my ($canonical, $alias) = _get_search_param_name($1, $2, $3);
-      ThrowUserError('product_versions_unavailable') unless $canonical;
+      ThrowUserError('product_version_pronouns_unavailable') unless $canonical;
       $params->{$key} = $canonical;
     }
   }
 }
 
+# Allow to use Firefox release date pronouns, including `%LAST_MERGE_DATE%`,
+# `%LAST_RELEASE_DATE%` and `%LAST_SOFTFREEZE_DATE%`.
+sub search_timestamp_translate {
+  my ($self, $args) = @_;
+  $args = $args->{args};
+  my $key = uc($args->{value});
+  $key =~ s/^%([A-Z_]+)%$/$1/;
+  my $keys = ['LAST_MERGE_DATE', 'LAST_RELEASE_DATE', 'LAST_SOFTFREEZE_DATE'];
+  return unless grep(/^$key$/, @$keys);
+
+  my $date = _fetch_product_version_file('firefox')->{$key};
+  ThrowUserError('product_date_pronouns_unavailable') unless $date;
+  $args->{value}  = $date;
+  $args->{quoted} = Bugzilla->dbh->quote($date);
+}
+
 sub tf_buglist_columns {
   my ($self, $args) = @_;
   my $columns = $args->{columns};
index b9c7adb134942591bab7d0ce13203f5cd8093e32..1bbf1dcdf317d39fbf07b8c23f0fec377c33a5fb 100644 (file)
   You cannot set this [% terms.bug %]'s status to ASSIGNED because the
   [%+ terms.bug %] is not assigned to a person.
 
-[% ELSIF error == "product_versions_unavailable" %]
-  [% title = "Product Version Info Unavailable" %]
+[% ELSIF error == "product_version_pronouns_unavailable" %]
+  [% title = "Product Version Pronouns Unavailable" %]
   The pronouns for Status and Tracking Flags cannot be used at this time.
   Please try again later or use actual version numbers instead.
 
+[% ELSIF error == "product_date_pronouns_unavailable" %]
+  [% title = "Product Date Pronouns Unavailable" %]
+  The pronoun for the merge date and release date cannot be used at this time.
+  Please try again later or use actual dates instead.
+
 [% END %]