[Bug 20947] New: Navigating to moremember.pl for a patron who has fines on deleted items causes software error.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 Bug ID: 20947 Summary: Navigating to moremember.pl for a patron who has fines on deleted items causes software error. Change sponsored?: --- Product: Koha Version: 17.11 Hardware: All OS: All Status: NEW Severity: critical Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: barton@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com Note this ONLY happens in 17.11 -- earlier versions of Koha don't have this code, and GetMemberAccountRecords does not exist in 18.05+ (per bug 12001)... however it is a major problem in 17.11. -- Steps to re-create: 1) Find a borrower with fines, preferably on an item that has already been checked in. 2) Delete the item 3) Navigate to moremember.pl for that borrower. This will trigger a software error with Can't call method "biblio" on an undefined value at /usr/share/koha/lib/C4/Members.pm line 767. in the plack-error.log Here's the code: 750 sub GetMemberAccountRecords { 751 my ($borrowernumber) = @_; 752 my $dbh = C4::Context->dbh; 753 my @acctlines; 754 my $numlines = 0; 755 my $strsth = qq( 756 SELECT * 757 FROM accountlines 758 WHERE borrowernumber=?); 759 $strsth.=" ORDER BY accountlines_id desc"; 760 my $sth= $dbh->prepare( $strsth ); 761 $sth->execute( $borrowernumber ); 762 763 my $total = 0; 764 while ( my $data = $sth->fetchrow_hashref ) { 765 if ( $data->{itemnumber} ) { 766 my $item = Koha::Items->find( $data->{itemnumber} ); 767 my $biblio = $item->biblio; The problem is that $data->{itemnumber}, (the itemnumber read from accountlines) may point to an active item or a deleted item. If the item was deleted, $item, as populated in my $item = Koha::Items->find( $data->{itemnumber} ); will be undef, and my $biblio = $item->biblio; Will throw the error message. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- I do not recreate, I noticed that accountlines.itemnumber is set to NULL when the item is deleted. Can you detail a bit more the steps to recreate? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 --- Comment #2 from Barton Chittenden <barton@bywatersolutions.com> --- (In reply to Jonathan Druart from comment #1)
I do not recreate, I noticed that accountlines.itemnumber is set to NULL when the item is deleted. Can you detail a bit more the steps to recreate?
The problem is triggered by accountlines records that have itemnumbers that don't point to items -- I honestly don't know *how* that happened -- manual database manipulation? Accountlines records that existed before the foreign key constraints? I think as a work-around, we're going to simply null accountlines.itemnumber and set accountlines.note using UPDATE accountlines SET note=CONCAT(itemnumber," item deleted from system"), itemnumber=NULL WHERE itemnumber NOT IN ( SELECT itemnumber FROM items ); I'm still open to a patch for this; but considering that the code that causes his no longer exists in master, and that I can't reproduce this by normal means in 17.11, I'm willing to use the workaround. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 --- Comment #3 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Could you confirm the FK is missing? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com --- Comment #4 from Nick Clemens <nick@bywatersolutions.com> --- (In reply to Jonathan Druart from comment #3)
Could you confirm the FK is missing?
Indeed, the foreign key appears to be missing on the affected site -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- It's not a new constraint, no idea how it could be possible. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20947 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WORKSFORME --- Comment #6 from Nick Clemens <nick@bywatersolutions.com> --- (In reply to Jonathan Druart from comment #5)
It's not a new constraint, no idea how it could be possible.
We suspect these sites were either original liblime dbs or created using outdated info. Closing this bug out as it shouldn't occur without bad tables -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org