]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1512815 - Store the list of all tracking flags in memcached.
authorDylan William Hardison <dylan@hardison.net>
Tue, 22 Jan 2019 22:43:59 +0000 (17:43 -0500)
committerGitHub <noreply@github.com>
Tue, 22 Jan 2019 22:43:59 +0000 (17:43 -0500)
Bugzilla/Search.pm
extensions/TrackingFlags/Extension.pm
extensions/TrackingFlags/lib/Flag.pm

index df2e787183dda6604977156c0210c0fa8d6dd98d..1dd5b72fbce54ea287d78333a720b1baa1520211 100644 (file)
@@ -736,8 +736,7 @@ sub data {
   # BMO - to avoid massive amounts of joins, if we're selecting a lot of
   # tracking flags, replace them with placeholders. the values will be
   # retrieved later and injected into the result.
-  my %tf_map
-    = map { $_ => 1 } Bugzilla::Extension::TrackingFlags::Flag->get_all_names();
+  my %tf_map = map { $_ => 1 } Bugzilla->tracking_flag_names;
   my @tf_selected = grep { exists $tf_map{$_} } @orig_fields;
 
   # mysql has a limit of 61 joins, and we want to avoid massive amounts of joins
index fea0240c8089459ef35b6feb5137925b0d7a1a0e..5879a5e55ac10355d0860d305982c64703869760 100644 (file)
@@ -43,7 +43,19 @@ sub _tracking_flags {
 }
 
 sub _tracking_flag_names {
-  return Bugzilla::Extension::TrackingFlags::Flag->get_all_names();
+  my ($class)   = @_;
+  my $memcached = $class->memcached;
+  my $cache     = $class->request_cache;
+  my $tf_names  = $cache->{tracking_flags_names};
+
+  return @$tf_names if $tf_names;
+  $tf_names //= $memcached->get_config({key => 'tracking_flag_names'});
+  $tf_names //= Bugzilla->dbh->selectcol_arrayref(
+    "SELECT name FROM tracking_flags ORDER BY name");
+
+  $cache->{tracking_flags_names} = $tf_names;
+
+  return @$tf_names;
 }
 
 sub page_before_template {
index 903b0534c2925100fc2edc56f03609e96a163f9c..b9ea41ebe6e8688284cff7becc17e164f06d67ae 100644 (file)
@@ -234,17 +234,6 @@ sub get_all {
     values %{$cache->{'tracking_flags'}};
 }
 
-# avoids the overhead of pre-loading if just the field names are required
-sub get_all_names {
-  my $self  = shift;
-  my $cache = Bugzilla->request_cache;
-  if (!exists $cache->{'tracking_flags_names'}) {
-    $cache->{'tracking_flags_names'} = Bugzilla->dbh->selectcol_arrayref(
-      "SELECT name FROM tracking_flags ORDER BY name");
-  }
-  return @{$cache->{'tracking_flags_names'}};
-}
-
 sub remove_from_db {
   my $self = shift;
   my $dbh  = Bugzilla->dbh;