diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2012-11-16 18:10:32 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2012-11-16 18:10:32 +0100 |
commit | 5fc1b86cfeeaf5e8e64dfbef3cd94f13a899d696 (patch) | |
tree | 78d6f36b43b9b6349af76fabeb8750af1a89f177 /Bugzilla | |
parent | 7605239f64f0b47fe3e96a9be0e07700b7bb5c7c (diff) | |
download | bugzilla-5fc1b86cfeeaf5e8e64dfbef3cd94f13a899d696.tar.gz bugzilla-5fc1b86cfeeaf5e8e64dfbef3cd94f13a899d696.tar.xz |
Bug 797636: Improve performance for buglists
r=dkl a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Config.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Template.pm | 5 | ||||
-rw-r--r-- | Bugzilla/Template/Context.pm | 7 | ||||
-rw-r--r-- | Bugzilla/Util.pm | 21 |
4 files changed, 24 insertions, 15 deletions
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm index f422de227..219bd6e31 100644 --- a/Bugzilla/Config.pm +++ b/Bugzilla/Config.pm @@ -13,7 +13,6 @@ use strict; use base qw(Exporter); use Bugzilla::Constants; use Bugzilla::Hook; -use Bugzilla::Install::Filesystem qw(fix_file_permissions); use Data::Dumper; use File::Temp; @@ -279,7 +278,10 @@ sub write_params { rename $tmpname, $param_file or die "Can't rename $tmpname to $param_file: $!"; - fix_file_permissions($param_file); + # It's not common to edit parameters and loading + # Bugzilla::Install::Filesystem is slow. + require Bugzilla::Install::Filesystem; + Bugzilla::Install::Filesystem::fix_file_permissions($param_file); # And now we have to reset the params cache so that Bugzilla will re-read # them. diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index d00799900..e13efec2b 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -562,10 +562,9 @@ $Template::Stash::SCALAR_OPS->{ 0 } = $Template::Stash::SCALAR_OPS->{ truncate } = sub { my ($string, $length, $ellipsis) = @_; - $ellipsis ||= ""; - return $string if !$length || length($string) <= $length; - + + $ellipsis ||= ''; my $strlen = $length - length($ellipsis); my $newstr = substr($string, 0, $strlen) . $ellipsis; return $newstr; diff --git a/Bugzilla/Template/Context.pm b/Bugzilla/Template/Context.pm index 937ac33b1..1edc0422c 100644 --- a/Bugzilla/Template/Context.pm +++ b/Bugzilla/Template/Context.pm @@ -84,6 +84,13 @@ sub stash { return $stash; } +sub filter { + my ($self, $name, $args) = @_; + # If we pass an alias for the filter name, the filter code is cached + # instead of looking for it at each call. + $self->SUPER::filter($name, $args, $name); +} + # We need a DESTROY sub for the same reason that Bugzilla::CGI does. sub DESTROY { my $self = shift; diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index db25cd27c..002f30ece 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -34,7 +34,6 @@ use Digest; use Email::Address; use List::Util qw(first); use Scalar::Util qw(tainted blessed); -use Template::Filters; use Text::Wrap; use Encode qw(encode decode resolve_alias); use Encode::Guess; @@ -64,7 +63,11 @@ sub detaint_signed { # visible strings. # Bug 319331: Handle BiDi disruptions. sub html_quote { - my ($var) = Template::Filters::html_filter(@_); + my $var = shift; + $var =~ s/&/&/g; + $var =~ s/</</g; + $var =~ s/>/>/g; + $var =~ s/"/"/g; # Obscure '@'. $var =~ s/\@/\@/g; if (Bugzilla->params->{'utf8'}) { @@ -705,10 +708,12 @@ sub get_text { sub template_var { my $name = shift; - my $cache = Bugzilla->request_cache->{util_template_var} ||= {}; - my $template = Bugzilla->template_inner; - my $lang = $template->context->{bz_language}; + my $request_cache = Bugzilla->request_cache; + my $cache = $request_cache->{util_template_var} ||= {}; + my $lang = $request_cache->{template_current_lang}->[0]; return $cache->{$lang}->{$name} if defined $cache->{$lang}; + + my $template = Bugzilla->template_inner($lang); my %vars; # Note: If we suddenly start needing a lot of template_var variables, # they should move into their own template, not field-descs. @@ -722,11 +727,7 @@ sub template_var { sub display_value { my ($field, $value) = @_; - my $value_descs = template_var('value_descs'); - if (defined $value_descs->{$field}->{$value}) { - return $value_descs->{$field}->{$value}; - } - return $value; + return template_var('value_descs')->{$field}->{$value} // $value; } sub disable_utf8 { |