Bug 40903 - OPAC advanced search applies a location limit of the logged-in library by default
Summary: OPAC advanced search applies a location limit of the logged-in library by def...
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Fridolin Somers
QA Contact: Aleisha Amohia
URL:
Keywords:
Depends on: 36742
Blocks:
  Show dependency treegraph
 
Reported: 2025-09-30 02:53 UTC by Aleisha Amohia
Modified: 2025-10-31 21:29 UTC (History)
3 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:


Attachments
Bug 40903: OPAC advanced search should not apply a limit of the logged-in library by default (1.66 KB, patch)
2025-10-27 11:00 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default (1.98 KB, patch)
2025-10-28 10:08 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default (2.03 KB, patch)
2025-10-28 20:52 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default (2.08 KB, patch)
2025-10-29 00:56 UTC, David Cook
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2025-09-30 02:53:09 UTC
This is caused by Bug 36742. It exists in main but starts in 24.11.

The OPAC advanced search now automatically applies a limit to the 'Location and availability' section using the patron's logged in library, even if there are multiple libraries in the system.
Comment 1 Fridolin Somers 2025-10-27 09:40:24 UTC
I confirm, will try to patch
Comment 2 Fridolin Somers 2025-10-27 09:43:31 UTC
Ohhh there is the arg "do_not_select_my_library => 1"
Comment 3 Fridolin Somers 2025-10-27 11:00:34 UTC
Created attachment 188467 [details] [review]
Bug 40903: OPAC advanced search should not apply a limit of the logged-in library by default

This is caused by Bug 36742. It exists in main but starts in 24.11.

The OPAC advanced search now automatically applies a limit to the 'Location and availability' section using the patron's logged in library, even if there are multiple libraries in the system.

1) Go to OPAC
2) Authenticate with a user
3) Go to advanced search
4) Check there is no library selected in 'Location and availability'
5) Select a library and submit
6) Clik on 'Return to the last advanced search'
7) Check the library is selected in 'Location and availability'
Comment 4 David Cook 2025-10-27 23:06:32 UTC
I'm a bit confused... 

This behaviour does not seem related to bug 36742. 

Rather, it's been a standard part of Koha for a very long time? Like the code has been part of Koha/Template/Plugin/Branches.pm for about 10 years and before that I think it was in C4/Branches.pm?
Comment 5 Fridolin Somers 2025-10-28 08:48:24 UTC
A library was upgraded from 22.11 to 24.11 so they complained about this change.

I'v checked 22.11 and 23.11, I see there is no default library limit.
Comment 6 Fridolin Somers 2025-10-28 08:51:06 UTC
Ahhh the code before 24.11 was calling :
  [% FOREACH BranchesLoo IN Branches.all( selected => opac_name ) %]
'opac_name' comming from C4::Auth and depending on system preference 'SearchMyLibraryFirst'.

So we must use the same 'selected' I bet.
And add system preference 'SearchMyLibraryFirst' to the test plan.
Comment 7 Fridolin Somers 2025-10-28 10:08:49 UTC
Created attachment 188501 [details] [review]
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default

This is caused by Bug 36742. It exists in main but starts in 24.11.

The OPAC advanced search now automatically applies a limit to the 'Location and availability' section using the patron's logged in library, even if there are multiple libraries in the system.
This feature must be depending on system preference 'SearchMyLibraryFirst'.

1) Set system preference 'SearchMyLibraryFirst' to 'Don't limit'
2) Go to OPAC
3) Authenticate with a user
4) Go to advanced search
5) Check there is no library selected in 'Location and availability'
6) Select a library and submit
7) Clik on 'Return to the last advanced search'
8) Check the library is selected in 'Location and availability'
9) Set system preference 'SearchMyLibraryFirst' to 'Limit'
10) Go to OPAC
11) Authenticate with a user
12) Go to advanced search
13) Check library of patron selected in 'Location and availability'
Comment 8 Aleisha Amohia 2025-10-28 20:52:09 UTC
Created attachment 188527 [details] [review]
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default

This is caused by Bug 36742. It exists in main but starts in 24.11.

The OPAC advanced search now automatically applies a limit to the 'Location and availability' section using the patron's logged in library, even if there are multiple libraries in the system.
This feature must be depending on system preference 'SearchMyLibraryFirst'.

1) Set system preference 'SearchMyLibraryFirst' to 'Don't limit'
2) Go to OPAC
3) Authenticate with a user
4) Go to advanced search
5) Check there is no library selected in 'Location and availability'
6) Select a library and submit
7) Clik on 'Return to the last advanced search'
8) Check the library is selected in 'Location and availability'
9) Set system preference 'SearchMyLibraryFirst' to 'Limit'
10) Go to OPAC
11) Authenticate with a user
12) Go to advanced search
13) Check library of patron selected in 'Location and availability'

Signed-off-by: Aleisha Amohia <aleisha@catalyst.net.nz>
Comment 9 David Cook 2025-10-28 23:32:27 UTC
(In reply to Fridolin Somers from comment #6)
> Ahhh the code before 24.11 was calling :
>   [% FOREACH BranchesLoo IN Branches.all( selected => opac_name ) %]
> 'opac_name' comming from C4::Auth and depending on system preference
> 'SearchMyLibraryFirst'.
> 
> So we must use the same 'selected' I bet.
> And add system preference 'SearchMyLibraryFirst' to the test plan.

Ahh interesting. 

The older libraries I checked appear to be using SearchMyLibraryFirst, which is why it seemed like older versions worked the same way. 

Nice one, Frido!
Comment 10 Aleisha Amohia 2025-10-28 23:52:16 UTC
(In reply to David Cook from comment #4)
> I'm a bit confused... 
> 
> This behaviour does not seem related to bug 36742. 
> 

For what it's worth, I had done a git cherry-pick which narrowed this behaviour down to the patch from Bug 36742!
Comment 11 David Cook 2025-10-29 00:46:56 UTC
(In reply to Aleisha Amohia from comment #10)
> (In reply to David Cook from comment #4)
> > I'm a bit confused... 
> > 
> > This behaviour does not seem related to bug 36742. 
> > 
> 
> For what it's worth, I had done a git cherry-pick which narrowed this
> behaviour down to the patch from Bug 36742!

My bad! 

I think I must've misread bug 36742 as well, as I think it ends up doing the thing is says it doesn't want to do in the description. Oh well... 

I'll have a crack at QAing this shortly.
Comment 12 David Cook 2025-10-29 00:56:44 UTC
Created attachment 188536 [details] [review]
Bug 40903: Fix OPAC advanced search applies a limit of the logged-in library by default

This is caused by Bug 36742. It exists in main but starts in 24.11.

The OPAC advanced search now automatically applies a limit to the 'Location and availability' section using the patron's logged in library, even if there are multiple libraries in the system.
This feature must be depending on system preference 'SearchMyLibraryFirst'.

1) Set system preference 'SearchMyLibraryFirst' to 'Don't limit'
2) Go to OPAC
3) Authenticate with a user
4) Go to advanced search
5) Check there is no library selected in 'Location and availability'
6) Select a library and submit
7) Clik on 'Return to the last advanced search'
8) Check the library is selected in 'Location and availability'
9) Set system preference 'SearchMyLibraryFirst' to 'Limit'
10) Go to OPAC
11) Authenticate with a user
12) Go to advanced search
13) Check library of patron selected in 'Location and availability'

Signed-off-by: Aleisha Amohia <aleisha@catalyst.net.nz>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Comment 13 Lucas Gass (lukeg) 2025-10-31 21:29:57 UTC
Nice work everyone!

Pushed to main for 25.11