Bug 31421

Summary: Library limitation on patron category breaks patron search
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: PatronsAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: critical    
Priority: P5 - low CC: arthur.suzuki, gmcharlt, jonathan.druart, kyle.m.hall, lucas, m.de.rooy, nick, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31422
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.07
Circulation function:
Attachments: Bug 31421: Do not apply library limits to Categories plugin
Bug 31421: Do not apply library limits to Categories plugin
Bug 31421: Add a limited option to template plugin
Bug 31421: (follow-up) Add POD
Bug 31421: Do not apply library limits to Categories plugin
Bug 31421: Add a limited option to template plugin
Bug 31421: Add tests

Description Katrin Fischer 2022-08-19 15:02:47 UTC
To test:

* Log in under library A (Fairfield)
* Limit one patron category (Patrons PT) to library B (Centerville)
* Search for all patrons (empty search)
* No results and there is an error in the console:

Uncaught TypeError: categories_map[data] is undefined
Comment 1 Nick Clemens (kidclamp) 2022-10-06 19:18:55 UTC
*** Bug 31686 has been marked as a duplicate of this bug. ***
Comment 2 Nick Clemens (kidclamp) 2022-10-06 19:19:39 UTC
Created attachment 141468 [details] [review]
Bug 31421: Do not apply library limits to Categories plugin

This patch simply changes from using 'search_with_library_limits'
to 'search'

The limits I think are intended to prevent users from setting a patron to the wrong category,
they are not meant to hide patrons. Or rather, they don't do that, patrons are returned in search
but cannot be processed. The dropdowns as well won't contain the category, so you can see these
patrons, but not filter by the category

Bug 31422 and bug 31032 point out further issues with limits.

For now, let's fix searching

To test:
1 - Edit Patron category 'Patron/PT'
2 - Try to do a patron search that returns patrons in this category
3 - See 'Processing' and error in JS console: Uncaught TypeError: categories_map[data] is undefined
4 - Apply patch
5 - Restart all and repeate
6 - It works now!
Comment 3 David Nind 2022-10-07 07:20:31 UTC
Created attachment 141479 [details] [review]
Bug 31421: Do not apply library limits to Categories plugin

This patch simply changes from using 'search_with_library_limits'
to 'search'

The limits I think are intended to prevent users from setting a patron to the wrong category,
they are not meant to hide patrons. Or rather, they don't do that, patrons are returned in search
but cannot be processed. The dropdowns as well won't contain the category, so you can see these
patrons, but not filter by the category

Bug 31422 and bug 31032 point out further issues with limits.

For now, let's fix searching

To test:
1 - Edit Patron category 'Patron/PT'
2 - Try to do a patron search that returns patrons in this category
3 - See 'Processing' and error in JS console: Uncaught TypeError: categories_map[data] is undefined
4 - Apply patch
5 - Restart all and repeate
6 - It works now!

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Jonathan Druart 2022-10-20 13:51:13 UTC
Non-limited categories is displayed in the "New patron" dropdown list

https://snipboard.io/043TZt.jpg

> The limits I think are intended to prevent users from setting a patron to the wrong category, they are not meant to hide patrons.

Is that correct? Yes I know I am the one who wrote bug 7919, but not the one who design it. And I have to admit I have no idea how it's supposed to work right now...
Comment 5 Jonathan Druart 2022-10-20 13:52:28 UTC
(In reply to Jonathan Druart from comment #4)
> Non-limited categories is displayed in the "New patron" dropdown list

Sorry, *limited* categories.
Comment 6 Nick Clemens (kidclamp) 2022-10-20 14:15:00 UTC
Created attachment 142247 [details] [review]
Bug 31421: Add a limited option to template plugin

This adds a specific 'limited' routine to the Categories plugin, and uses
it for the new patron dropdowns

To test:
1 - Limit a patron category to some branches
2 - Sign in not at one of those
3 - Confirm the new patron dropdowns don't include the category
Comment 7 Marcel de Rooy 2022-10-21 07:16:14 UTC
 FAIL   Koha/Template/Plugin/Categories.pm
   OK     critic
   OK     forbidden patterns
   OK     git manipulation
   OK     pod
   FAIL   pod coverage
                POD is missing for 'limited'
Comment 8 Nick Clemens (kidclamp) 2022-10-21 11:32:12 UTC
Created attachment 142332 [details] [review]
Bug 31421: (follow-up) Add POD
Comment 9 Jonathan Druart 2022-10-27 10:41:27 UTC
Created attachment 142705 [details] [review]
Bug 31421: Do not apply library limits to Categories plugin

This patch simply changes from using 'search_with_library_limits'
to 'search'

The limits I think are intended to prevent users from setting a patron to the wrong category,
they are not meant to hide patrons. Or rather, they don't do that, patrons are returned in search
but cannot be processed. The dropdowns as well won't contain the category, so you can see these
patrons, but not filter by the category

Bug 31422 and bug 31032 point out further issues with limits.

For now, let's fix searching

To test:
1 - Edit Patron category 'Patron/PT'
2 - Try to do a patron search that returns patrons in this category
3 - See 'Processing' and error in JS console: Uncaught TypeError: categories_map[data] is undefined
4 - Apply patch
5 - Restart all and repeate
6 - It works now!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 10 Jonathan Druart 2022-10-27 10:41:32 UTC
Created attachment 142706 [details] [review]
Bug 31421: Add a limited option to template plugin

This adds a specific 'limited' routine to the Categories plugin, and uses
it for the new patron dropdowns

To test:
1 - Limit a patron category to some branches
2 - Sign in not at one of those
3 - Confirm the new patron dropdowns don't include the category

Bug 31421: (follow-up) Add POD

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Jonathan Druart 2022-10-27 10:41:36 UTC
Created attachment 142707 [details] [review]
Bug 31421: Add tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Tomás Cohen Arazi (tcohen) 2022-10-27 12:44:27 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 13 Lucas Gass (lukeg) 2022-10-28 17:52:41 UTC
Backported to 22.05.x for upcoming 22.05.07 release
Comment 14 Arthur Suzuki 2022-11-14 10:57:46 UTC
applied to 21.11.x for 21.11.14
Comment 15 Victor Grousset/tuxayo 2022-11-18 01:12:16 UTC
21.05.x not affected, no backport.
Nothing to document it seems, marking resolved.
Comment 16 Arthur Suzuki 2022-11-21 10:00:43 UTC
revert on 21.11. bug actually not reproduced.