Bugzilla – Attachment 49588 Details for
Bug 16088
Excessive CGI->new() calls hurting cache performace under plack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16088: [POC] Koha::CGI - Do no create a new CGI object to access the language
Bug-16088-POC-KohaCGI---Do-no-create-a-new-CGI-obj.patch (text/plain), 2.76 KB, created by
Jonathan Druart
on 2016-03-25 13:22:33 UTC
(
hide
)
Description:
Bug 16088: [POC] Koha::CGI - Do no create a new CGI object to access the language
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-03-25 13:22:33 UTC
Size:
2.76 KB
patch
obsolete
>From d93d238b469c40ac884c411d5540d0d8ef99d5d6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 18 Mar 2016 15:52:06 +0000 >Subject: [PATCH] Bug 16088: [POC] Koha::CGI - Do no create a new CGI object to > access the language > >--- > C4/Languages.pm | 12 ++++-------- > Koha/CGI.pm | 20 ++++++++++++++++++++ > catalogue/search.pl | 4 ++-- > 3 files changed, 26 insertions(+), 10 deletions(-) > create mode 100644 Koha/CGI.pm > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index affe96c..5719fb1 100644 >--- a/C4/Languages.pm >+++ b/C4/Languages.pm >@@ -26,6 +26,7 @@ use Carp; > use CGI; > use List::MoreUtils qw( any ); > use C4::Context; >+use Koha::CGI; > use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); > > eval { >@@ -569,7 +570,6 @@ sub accept_language { > sub getlanguage { > my ($cgi) = @_; > >- $cgi //= new CGI; > my $interface = C4::Context->interface; > my $theme = C4::Context->preference( ( $interface eq 'opac' ) ? 'opacthemes' : 'template' ); > my $language; >@@ -583,17 +583,13 @@ sub getlanguage { > @languages = split /,/, $preference_value; > } > >- # Chose language from the URL >- $language = $cgi->param( 'language' ); >+ # Chose language from the URL or the cookie >+ $language = $cgi ? $cgi->param( 'language' ) || $cgi->cookie('KohaOpacLanguage') : Koha::CGI->language; >+ $language =~ s/[^a-zA-Z_-]*//; # sanitize cookie > if ( defined $language && any { $_ eq $language } @languages) { > return $language; > } > >- # cookie >- if ($language = $cgi->cookie('KohaOpacLanguage') ) { >- $language =~ s/[^a-zA-Z_-]*//; # sanitize cookie >- } >- > # HTTP_ACCEPT_LANGUAGE > if ( !$language && $ENV{HTTP_ACCEPT_LANGUAGE} ) { > $language = accept_language( $ENV{HTTP_ACCEPT_LANGUAGE}, >diff --git a/Koha/CGI.pm b/Koha/CGI.pm >new file mode 100644 >index 0000000..99d775f >--- /dev/null >+++ b/Koha/CGI.pm >@@ -0,0 +1,20 @@ >+package Koha::CGI; >+ >+use Modern::Perl; >+ >+#use base CGI; >+ >+our $language; >+sub new { >+ my $self = CGI->new; >+ $language = $self->param('language') || $self->cookie('KohaOpacLanguage'); >+ return $self; >+} >+sub language { >+ my ( $class ) = @_; >+ return $language if $language; >+ $class->new; >+ return $language; >+} >+ >+1; >diff --git a/catalogue/search.pl b/catalogue/search.pl >index fe5d45d..8e4d5d6 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -160,8 +160,8 @@ use URI::Escape; > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > # create a new CGI object > # FIXME: no_undef_params needs to be tested >-use CGI qw('-no_undef_params' -utf8 ); >-my $cgi = new CGI; >+use Koha::CGI qw('-no_undef_params' -utf8 ); >+my $cgi = Koha::CGI->new; > > # decide which template to use > my $template_name; >-- >2.7.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16088
:
49322
|
49489
|
49588
|
51335
|
51392
|
51398
|
51405
|
51415
|
51418
|
51420
|
51429
|
52008
|
52009