From: Kohei Yoshino Date: Wed, 26 Jun 2019 21:25:20 +0000 (-0400) Subject: Bug 1531968 - Allow to search bugs by Firefox merge dates X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fac82a6be59f9a3ea299d61f4618f23dec61b66d;p=thirdparty%2Fbugzilla.git Bug 1531968 - Allow to search bugs by Firefox merge dates --- diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index 888f8884e..b4f061ef9 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -597,6 +597,22 @@ Params: =back +=head2 search_timestamp_translate + +This happens in L 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 - The L object. + +=item C - The original arguments including C. + +=back + =head2 search_operator_field_override This allows you to modify L, diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index b9f1ea283..e765c07a8 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -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); diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index dbab0e5c6..aeeb5d07a 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -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}; diff --git a/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl index b9c7adb13..1bbf1dcdf 100644 --- a/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/BMO/template/en/default/hook/global/user-error-errors.html.tmpl @@ -46,9 +46,14 @@ 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 %]