Bug 29332

Summary: AdditionalContents displays blocks for every library prior to login
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: OPACAssignee: Martin Renvoize <martin.renvoize>
Status: CLOSED FIXED QA Contact: Owen Leonard <oleonard>
Severity: major    
Priority: P5 - low CC: andrewfh, jonathan.druart, kyle, lucas, nick
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00
Bug Depends on:    
Bug Blocks: 28955    
Attachments: Bug 29332: Set default library limits in search_for_display
Bug 29332: Unit tests
Bug 29332: Set default library limits in search_for_display
Bug 29332: Set default library limits in search_for_display
Bug 29332: Unit tests
Bug 29332: Set default library limits in search_for_display

Description Martin Renvoize 2021-10-27 10:49:24 UTC
If you set a content block to display only for one library, you do not want it to show prior to that library being defined.  Currently, prior to OPAC login, all blocks will display as the library is not yet set.. only the 'all' block should display.
Comment 1 Martin Renvoize 2021-10-27 10:54:57 UTC
Created attachment 126960 [details] [review]
Bug 29332: Set default library limits in search_for_display

Koha::AdditionalContents->search_for_display needs to filter to just
items with a 'null' branchcode if no library_id is passed.

Test plan
1/ Add some additional content blocks that should display only for
specific branches.
2/ Navigate to the OPAC and note that blocks display for all libraries
prior to login
3/ Login to the OPAC and note that now you only see you users library
block
4/ Apply the patch
5/ Repeat steps 2 and 3 and note that now you see only the 'All
libraries' blocks display prior to login and that 'All libraries' +
'Your users library' blocks appear after login.
Comment 2 Martin Renvoize 2021-10-27 11:08:30 UTC
Created attachment 126962 [details] [review]
Bug 29332: Unit tests

This patch adds unit tests to ensure we do not leak branch specific
addtional contents blocks outside of logged in sessions (i.e. where a
users branch is not yet set).
Comment 3 Martin Renvoize 2021-10-27 11:08:34 UTC
Created attachment 126963 [details] [review]
Bug 29332: Set default library limits in search_for_display

Koha::AdditionalContents->search_for_display needs to filter to just
items with a 'null' branchcode if no library_id is passed.

Test plan
1/ Add some additional content blocks that should display only for
specific branches.
2/ Navigate to the OPAC and note that blocks display for all libraries
prior to login
3/ Login to the OPAC and note that now you only see you users library
block
4/ Apply the patch
5/ Repeat steps 2 and 3 and note that now you see only the 'All
libraries' blocks display prior to login and that 'All libraries' +
'Your users library' blocks appear after login.
Comment 4 Nick Clemens 2021-10-27 13:13:38 UTC
Created attachment 126991 [details] [review]
Bug 29332: Set default library limits in search_for_display

Koha::AdditionalContents->search_for_display needs to filter to just
items with a 'null' branchcode if no library_id is passed.

Test plan
1/ Add some additional content blocks that should display only for
specific branches.
2/ Navigate to the OPAC and note that blocks display for all libraries
prior to login
3/ Login to the OPAC and note that now you only see you users library
block
4/ Apply the patch
5/ Repeat steps 2 and 3 and note that now you see only the 'All
libraries' blocks display prior to login and that 'All libraries' +
'Your users library' blocks appear after login.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Nick Clemens 2021-10-27 13:14:04 UTC
Created attachment 126992 [details] [review]
Bug 29332: Unit tests

This patch adds unit tests to ensure we do not leak branch specific
addtional contents blocks outside of logged in sessions (i.e. where a
users branch is not yet set).

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Nick Clemens 2021-10-27 13:14:08 UTC
Created attachment 126993 [details] [review]
Bug 29332: Set default library limits in search_for_display

Koha::AdditionalContents->search_for_display needs to filter to just
items with a 'null' branchcode if no library_id is passed.

Test plan
1/ Add some additional content blocks that should display only for
specific branches.
2/ Navigate to the OPAC and note that blocks display for all libraries
prior to login
3/ Login to the OPAC and note that now you only see you users library
block
4/ Apply the patch
5/ Repeat steps 2 and 3 and note that now you see only the 'All
libraries' blocks display prior to login and that 'All libraries' +
'Your users library' blocks appear after login.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 7 Nick Clemens 2021-10-27 13:14:32 UTC
Straight forward fix with test, PQA
Comment 8 Jonathan Druart 2021-10-28 10:30:23 UTC
Pushed to master for 21.11, thanks to everybody involved!