From 0334d6004fe0b2640f261455ff33594f44643e33 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 2 Oct 2019 16:28:21 +0200 Subject: [PATCH] Bug 21301: Remove patron informations in issues for GetRecords ILS-DI service Actually, the GetRecords service gives many information : bibliographic data (marcxml field) item data (items field) issue data (issues field) The issue data should not be sent by these service, its a privacy problem. Biblio title and author are redundant. This patch changes to use Koha::Checkouts to get issues informations with only the addition of item barcode. Test plan : 1) Enable ILS-DI webservice 2) Checkout an item 3) Go to {opac}/cgi-bin/koha/ilsdi.pl?service=GetRecords&id={biblionumber} 4) Check the issues tag content Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 45 ------------------------------ C4/ILSDI/Services.pm | 11 ++++++-- t/db_dependent/Circulation/issue.t | 4 --- 3 files changed, 9 insertions(+), 51 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ad617c846e..ab49c05078 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -99,7 +99,6 @@ BEGIN { &GetIssuingCharges &GetBranchBorrowerCircRule &GetBranchItemRule - &GetBiblioIssues &GetOpenIssue &CheckIfIssuedToPatron &IsItemIssued @@ -2553,50 +2552,6 @@ sub GetOpenIssue { } -=head2 GetBiblioIssues - - $issues = GetBiblioIssues($biblionumber); - -this function get all issues from a biblionumber. - -Return: -C<$issues> is a reference to array which each value is ref-to-hash. This ref-to-hash contains all column from -tables issues and the firstname,surname & cardnumber from borrowers. - -=cut - -sub GetBiblioIssues { - my $biblionumber = shift; - return unless $biblionumber; - my $dbh = C4::Context->dbh; - my $query = " - SELECT issues.*,items.barcode,biblio.biblionumber,biblio.title, biblio.author,borrowers.cardnumber,borrowers.surname,borrowers.firstname - FROM issues - LEFT JOIN borrowers ON borrowers.borrowernumber = issues.borrowernumber - LEFT JOIN items ON issues.itemnumber = items.itemnumber - LEFT JOIN biblioitems ON items.itemnumber = biblioitems.biblioitemnumber - LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber - WHERE biblio.biblionumber = ? - UNION ALL - SELECT old_issues.*,items.barcode,biblio.biblionumber,biblio.title, biblio.author,borrowers.cardnumber,borrowers.surname,borrowers.firstname - FROM old_issues - LEFT JOIN borrowers ON borrowers.borrowernumber = old_issues.borrowernumber - LEFT JOIN items ON old_issues.itemnumber = items.itemnumber - LEFT JOIN biblioitems ON items.itemnumber = biblioitems.biblioitemnumber - LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber - WHERE biblio.biblionumber = ? - ORDER BY timestamp - "; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber, $biblionumber); - - my @issues; - while ( my $data = $sth->fetchrow_hashref ) { - push @issues, $data; - } - return \@issues; -} - =head2 GetUpcomingDueIssues my $upcoming_dues = GetUpcomingDueIssues( { days_in_advance => 4 } ); diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 64caa4a6fa..9ee2043579 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -229,7 +229,14 @@ sub GetRecords { # Get most of the needed data my $biblioitemnumber = $biblioitem->{'biblioitemnumber'}; my $holds = $biblio->current_holds->unblessed; - my $issues = GetBiblioIssues($biblionumber); + my $checkouts = Koha::Checkouts->search( + { biblionumber => $biblionumber }, + { + join => 'item', + '+select' => ['item.barcode'], + '+as' => ['barcode'], + } + )->unblessed; my @items = $biblio->items->as_list; $biblioitem->{items}->{item} = []; @@ -261,7 +268,7 @@ sub GetRecords { # Hashref building... $biblioitem->{'reserves'}->{'reserve'} = $holds; - $biblioitem->{'issues'}->{'issue'} = $issues; + $biblioitem->{'issues'}->{'issue'} = $checkouts; push @records, $biblioitem; } diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index 81d98bdd5f..49b9fc1148 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -46,7 +46,6 @@ can_ok( AddIssuingCharge AddRenewal AddReturn - GetBiblioIssues GetIssuingCharges GetOpenIssue GetRenewCount @@ -263,9 +262,6 @@ ok( $stat, "Bug 18572 - 'Bug 18572 - OpacRenewalBranch is now respected" ); -#Test GetBiblioIssues -is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); - #Test GetOpenIssue is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" ); is( GetOpenIssue(-1), undef, -- 2.20.1