Bug 34145 - Patron search broken
Summary: Patron search broken
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-28 12:41 UTC by Justin Dowswell
Modified: 2024-02-21 17:19 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 34145: Allow access the logged in branch's limited data (794 bytes, patch)
2023-07-05 11:06 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Dowswell 2023-06-28 12:41:08 UTC
This is my console output:

Uncaught TypeError: Cannot read properties of undefined (reading 'branchname')
    at render (members-home.pl:2483:76)
    at datatables.min_23.0500000.js:56:435
    at b.fnGetData (datatables.min_23.0500000.js:50:221)
    at B (datatables.min_23.0500000.js:55:141)
    at Ha (datatables.min_23.0500000.js:63:1)
    at P (datatables.min_23.0500000.js:67:433)
    at vb (datatables.min_23.0500000.js:78:98)
    at datatables.min_23.0500000.js:75:167
    at i (datatables.min_23.0500000.js:73:338)
    at Object.success (datatables.min_23.0500000.js:74:40)

And this is where branchname appears in members-home.pl:

in 

    {
                                "data": "library_id",
                                "searchable": true,
                                "orderable": true,
                                "render": function( data, type, row, meta ) {
                                    let library_name = libraries_map[data].branchname
                                    if( !singleBranchMode && data == logged_in_library_id ) {
                                        return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>";
                                    } else {
                                        return escape_str(library_name);
                                    }
                                }
                            }

It seems that this bug may be related: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31421

Though it says a fix was pushed to stable.
Comment 1 Paul Derscheid 2023-06-29 12:44:33 UTC
How can I reproduce this?
Comment 2 Jonathan Druart 2023-07-05 11:05:45 UTC
I think there is a confusion in Koha::Libraries->search_filtered, and we don't add the logged in library.
Comment 3 Jonathan Druart 2023-07-05 11:06:54 UTC
Created attachment 153051 [details] [review]
Bug 34145: Allow access the logged in branch's limited data
Comment 4 Jonathan Druart 2023-07-05 11:07:17 UTC
Justin, could you confirm this patch fixes your problem?
Comment 5 Jonathan Druart 2023-07-05 11:07:42 UTC
Nick, does this patch seem correct to you?
Comment 6 Marcel de Rooy 2023-07-05 11:25:53 UTC
The name is a killer :)
sub libraries_where_can_see_things
Comment 7 Nick Clemens (kidclamp) 2023-07-13 15:57:58 UTC
(In reply to Jonathan Druart from comment #5)
> Nick, does this patch seem correct to you?

I don't recreate, what is the setup?

Also, without view_borrower_infos_from_any_libraries you can log into another branch, but still can't see their patrons, so I don't think we should be adding the logged in branch. Can you explain why we should?
Comment 8 Katrin Fischer 2023-07-16 13:07:46 UTC
Can we get some non-code summary on what happens here and a test plan?
Comment 9 Jonathan Druart 2023-07-17 12:52:15 UTC
I didn't recreate, the patch was just a guess. See also bug 34147.
Comment 10 Katrin Fischer 2023-11-05 13:32:06 UTC
At the moment it looks like we have no information on how to make this bug appear. I have tested the patron search a lot for various bugs and couldn't detect an issue or this bug. I am downgrading this one.

Please provide more information!

* What is the exact version you are seeing this in
* What is your setup? (IndependentBranches? Library groups?)
Comment 11 Barry Cannon 2024-02-21 17:19:04 UTC
I am not sure how useful this is but I found an instance where this can be recreated. If the branchcode on the borrowers table  is in an different case to the branchcode on the branches table this problem can occur.

MySQL doesn't care about case sensitivity but when javascript gets a hold of it branchcode != BRANCHCODE.

Updating the borrowers table (or branches table) to make all the same case (upper or lower) resolved the issue.

23.11
Comment 12 Barry Cannon 2024-02-21 17:19:23 UTC
I am not sure how useful this is but I found an instance where this can be recreated. If the branchcode on the borrowers table  is in an different case to the branchcode on the branches table this problem can occur.

MySQL doesn't care about case sensitivity but when javascript gets a hold of it branchcode != BRANCHCODE.

Updating the borrowers table (or branches table) to make all the same case (upper or lower) resolved the issue.

23.11