]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1283310 - Optimizations for Bugzilla::active_custom_fields()
authorDylan Hardison <dylan@mozilla.com>
Thu, 30 Jun 2016 19:19:00 +0000 (15:19 -0400)
committerDylan Hardison <dylan@mozilla.com>
Thu, 30 Jun 2016 19:19:00 +0000 (15:19 -0400)
Bugzilla.pm
Bugzilla/Bug.pm
Bugzilla/Field.pm
extensions/TrackingFlags/Extension.pm

index 0f513aed66b475e5470cf193a22089300ee64284..4f80a2ed4b9a2589a95620a00c7ce4005015e540 100644 (file)
@@ -710,10 +710,10 @@ sub active_custom_fields {
     if ($params) {
         $cache_id .= ($params->{product} ? '_p' . $params->{product}->id : '') .
                      ($params->{component} ? '_c' . $params->{component}->id : '');
+        $cache_id .= ':noext' if $params->{skip_extensions};
     }
     if (!exists $class->request_cache->{$cache_id}) {
-        my $fields = Bugzilla::Field->match({ custom => 1, obsolete => 0});
-        @$fields = grep($_->type ne FIELD_TYPE_EXTENSION, @$fields);
+        my $fields = Bugzilla::Field->match({ custom => 1, obsolete => 0, skip_extensions => 1 });
         Bugzilla::Hook::process('active_custom_fields',
                                 { fields => \$fields, params => $params });
         $class->request_cache->{$cache_id} = $fields;
index 73dc989633a44a9b40fa724970980ba98709322e..09696f97b75fb81a3560acb5640dd1697252f979 100644 (file)
@@ -83,9 +83,8 @@ use constant USE_MEMCACHED => 0;
 # This is a sub because it needs to call other subroutines.
 sub DB_COLUMNS {
     my $dbh = Bugzilla->dbh;
-    my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT
-                       && $_->type != FIELD_TYPE_EXTENSION}
-                      Bugzilla->active_custom_fields;
+    my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT }
+                      Bugzilla->active_custom_fields({skip_extensions => 1});
     my @custom_names = map {$_->name} @custom;
 
     my @columns = (qw(
@@ -221,9 +220,8 @@ sub VALIDATOR_DEPENDENCIES {
 };
 
 sub UPDATE_COLUMNS {
-    my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT
-                       && $_->type != FIELD_TYPE_EXTENSION}
-                      Bugzilla->active_custom_fields;
+    my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT }
+                      Bugzilla->active_custom_fields({skip_extensions => 1});
     my @custom_names = map {$_->name} @custom;
     my @columns = qw(
         alias
index ea93327ad016a8b980eeffcaa745610c599cdb06..0a0c7b15fb5667e95d6231b1a08be2cc52dc4ab5 100644 (file)
@@ -288,6 +288,9 @@ sub match {
     if (delete $params->{is_select}) {
         $params->{type} = [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT];
     }
+    if (delete $params->{skip_extensions}) {
+        $params->{WHERE}{'type != ?'} = FIELD_TYPE_EXTENSION;
+    }
     return $self->SUPER::match(@_);
 }
 
index 33792dc38fb25718bb36b04a041ca0ee47e73659..b150faea27e1c5d519f1c604acb735e352fbebf4 100644 (file)
@@ -409,6 +409,7 @@ sub active_custom_fields {
     my $product   = $params->{'product'};
     my $component = $params->{'component'};
 
+    return if $params->{skip_extensions};
     # Create a hash of current fields based on field names
     my %field_hash = map { $_->name => $_ } @$$fields;