Bugzilla – Attachment 161482 Details for
Bug 35918
Incorrect library used when AutoLocation configured using the same IP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35918: Fix auto library connect (AutoLocation)
Bug-35918-Fix-auto-library-connect-AutoLocation.patch (text/plain), 2.68 KB, created by
Jonathan Druart
on 2024-01-26 08:01:20 UTC
(
hide
)
Description:
Bug 35918: Fix auto library connect (AutoLocation)
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-26 08:01:20 UTC
Size:
2.68 KB
patch
obsolete
>From c41f966ca1d1496e1f0a52c0a897b30cb61743df Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 26 Jan 2024 08:58:17 +0100 >Subject: [PATCH] Bug 35918: Fix auto library connect (AutoLocation) > >This code is a bit weird, its purpose it to auto select the library depending on the IP. >A problem appears if the same IP is used, then the user's choice will >might be overwritten randomly by another library. > >To recreate the problem: >Turn on AutoLocation >Use koha/koha @CPL for test >And the following config: >*************************** 1. row *************************** >branchcode: CPL >branchname: Centerville > branchip: 172.18.0.1 >*************************** 2. row *************************** >branchcode: FFL >branchname: Fairfield > branchip: 172.18.0.1 >*************************** 3. row *************************** >branchcode: FPL >branchname: Fairview > branchip: 172.18.0.4 > >Connect and select CPL. Randomly FFL will be picked instead. >--- > C4/Auth.pm | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 1d31c5b7466..7c77bb5a358 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -26,6 +26,7 @@ use CGI::Session; > use CGI::Session::ErrorHandler; > use URI; > use URI::QueryParam; >+use List::MoreUtils qw( uniq ); > > use C4::Context; > use C4::Templates; # to get the template >@@ -1211,15 +1212,18 @@ sub checkauth { > } > } > >- foreach my $br ( keys %$branches ) { >+ if ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' ) { >+ foreach my $br ( uniq( $branchcode, keys %$branches ) ) { > >- # now we work with the treatment of ip >- my $domain = $branches->{$br}->{'branchip'}; >- if ( $domain && $ip =~ /^$domain/ ) { >- $branchcode = $branches->{$br}->{'branchcode'}; >+ # now we work with the treatment of ip >+ my $domain = $branches->{$br}->{'branchip'}; >+ if ( $domain && $ip =~ /^$domain/ ) { >+ $branchcode = $branches->{$br}->{'branchcode'}; > >- # new op dev : add the branchname to the cookie >- $branchname = $branches->{$br}->{'branchname'}; >+ # new op dev : add the branchname to the cookie >+ $branchname = $branches->{$br}->{'branchname'}; >+ last; >+ } > } > } > >-- >2.34.1
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 35918
:
161481
|
161482
|
161541
|
161542
|
162155
|
162156