Bugzilla – Attachment 71832 Details for
Bug 19160
CAS Single Logout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19160: Move duplicated code to its own private subroutine
Bug-19160-Move-duplicated-code-to-its-own-private-.patch (text/plain), 4.32 KB, created by
Katrin Fischer
on 2018-02-16 17:09:44 UTC
(
hide
)
Description:
Bug 19160: Move duplicated code to its own private subroutine
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-02-16 17:09:44 UTC
Size:
4.32 KB
patch
obsolete
>From 6e10ef8968d050c37a8f0941432b5642e3277188 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 11 Jan 2018 15:29:22 -0300 >Subject: [PATCH] Bug 19160: Move duplicated code to its own private subroutine > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > C4/Auth.pm | 50 ++++++++++++++++---------------------------------- > 1 file changed, 16 insertions(+), 34 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 5df6f2e..b0b750e 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -909,31 +909,9 @@ sub checkauth { > # We got a cas single logout request from a cas server; > my $ticket = $query->param('cas_ticket'); > # We've been called as part of the single logout destroy the session associated with the cas ticket >- my $storage_method = C4::Context->preference('SessionStorage'); >- my $dsn; >- my $dsn_options; >- # shift this to a function make get_session use the function too >- my $dbh = C4::Context->dbh; >- if ( $storage_method eq 'mysql' ) { >- $dsn = "driver:MySQL;serializer:yaml;id:md5"; >- $dsn_options = { Handle => $dbh }; >- } >- elsif ( $storage_method eq 'Pg' ) { >- $dsn = "driver:PostgreSQL;serializer:yaml;id:md5"; >- $dsn_options = { Handle => $dbh }; >- } >- elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { >- $dsn = "driver:memcached;serializer:yaml;id:md5"; >- my $memcached = Koha::Caches->get_instance()->memcached_cache; >- $dsn_options = { Memcached => $memcached }; >- } >- else { >- $dsn = "driver:File;serializer:yaml;id:md5"; >- my $dir = File::Spec->tmpdir; >- my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is >- $dsn_options = { Directory => "$dir/cgisess_$instance" }; >- } >- my $success = CGI::Session->find( $dsn, sub {delete_cas_session(@_, $ticket)}, $dsn_options ); >+ my $params = _get_session_params(); >+ my $success = CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} ); >+ > sub delete_cas_session { > my $session = shift; > my $ticket = shift; >@@ -1770,28 +1748,32 @@ will be created. > > =cut > >-sub get_session { >- my $sessionID = shift; >+sub _get_session_params { > my $storage_method = C4::Context->preference('SessionStorage'); >- my $dbh = C4::Context->dbh; >- my $session; > if ( $storage_method eq 'mysql' ) { >- $session = new CGI::Session( "driver:MySQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } ); >+ my $dbh = C4::Context->dbh; >+ return { dsn => "driver:MySQL;serializer:yaml;id:md5", dsn_args => { Handle => $dbh } }; > } > elsif ( $storage_method eq 'Pg' ) { >- $session = new CGI::Session( "driver:PostgreSQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } ); >+ my $dbh = C4::Context->dbh; >+ return { dsn => "driver:PostgreSQL;serializer:yaml;id:md5", dsn_args => { Handle => $dbh } }; > } > elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { > my $memcached = Koha::Caches->get_instance()->memcached_cache; >- $session = new CGI::Session( "driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => $memcached } ); >+ return { dsn => "driver:memcached;serializer:yaml;id:md5", dsn_args => { Memcached => $memcached } }; > } > else { > # catch all defaults to tmp should work on all systems > my $dir = File::Spec->tmpdir; > my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is >- $session = new CGI::Session( "driver:File;serializer:yaml;id:md5", $sessionID, { Directory => "$dir/cgisess_$instance" } ); >+ return { dsn => "driver:File;serializer:yaml;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } }; > } >- return $session; >+} >+ >+sub get_session { >+ my $sessionID = shift; >+ my $params = _get_session_params(); >+ return new CGI::Session( $params->{dsn}, $sessionID, $params->{dsn_args} ); > } > > >-- >2.1.4
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 19160
:
66285
|
66306
|
70408
|
70440
|
70441
|
70442
|
71829
|
71830
|
71831
|
71832
|
71833
|
71834
|
71835
|
72358
|
72359
|
72360
|
72361
|
72362
|
72363
|
72364