[bugzilla-gnome-org-upstream/4.4: 4/19] Bug 1082882: custom date field not recognized as date type in advanced search r=glob, a=glob



commit 9ca7310c3da28d752ec5f1dd6d6f93f78283d662
Author: David Lawrence <dkl mozilla com>
Date:   Tue Oct 21 13:58:58 2014 +0000

    Bug 1082882: custom date field not recognized as date type in advanced search
    r=glob,a=glob

 Bugzilla/Search.pm |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index b395b3f..eaab600 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -327,20 +327,29 @@ use constant OPERATOR_FIELD_OVERRIDE => {
 
 # These are fields where special action is taken depending on the
 # *value* passed in to the chart, sometimes.
-use constant SPECIAL_PARSING => {
-    # Pronoun Fields (Ones that can accept %user%, etc.)
-    assigned_to => \&_contact_pronoun,
-    cc          => \&_contact_pronoun,
-    commenter   => \&_contact_pronoun,
-    qa_contact  => \&_contact_pronoun,
-    reporter    => \&_contact_pronoun,
-    'setters.login_name' => \&_contact_pronoun,
-    'requestees.login_name' => \&_contact_pronoun,
-
-    # Date Fields that accept the 1d, 1w, 1m, 1y, etc. format.
-    creation_ts => \&_timestamp_translate,
-    deadline    => \&_timestamp_translate,
-    delta_ts    => \&_timestamp_translate,
+# This is a sub because custom fields are dynamic
+sub SPECIAL_PARSING {
+    my $map = {
+        # Pronoun Fields (Ones that can accept %user%, etc.)
+        assigned_to => \&_contact_pronoun,
+        cc          => \&_contact_pronoun,
+        commenter   => \&_contact_pronoun,
+        qa_contact  => \&_contact_pronoun,
+        reporter    => \&_contact_pronoun,
+        'setters.login_name' => \&_contact_pronoun,
+        'requestees.login_name' => \&_contact_pronoun,
+
+        # Date Fields that accept the 1d, 1w, 1m, 1y, etc. format.
+        creation_ts => \&_timestamp_translate,
+        deadline    => \&_timestamp_translate,
+        delta_ts    => \&_timestamp_translate,
+    };
+    foreach my $field (Bugzilla->active_custom_fields) {
+        if ($field->type == FIELD_TYPE_DATETIME) {
+            $map->{$field->name} = \&_timestamp_translate;
+        }
+    }
+    return $map;
 };
 
 # Information about fields that represent "users", used by _user_nonchanged.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]