From 177b6ca96eb8c080be35a67ef648b6c58892e50e 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 Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart (cherry picked from commit 8ae0ef6eb529cb866914ee8cffba469a9486a53c) Signed-off-by: Fridolin Somers (cherry picked from commit b6d2ea13c7517ecfa913a1f7d85e6ab3b8775f1e) Signed-off-by: Andrew Fuerste-Henry --- 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 39ef3fff55..8ac087ef71 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -98,7 +98,6 @@ BEGIN { &GetIssuingCharges &GetBranchBorrowerCircRule &GetBranchItemRule - &GetBiblioIssues &GetOpenIssue &CheckIfIssuedToPatron &IsItemIssued @@ -2623,50 +2622,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 5ebba3435d..06e82f952c 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -228,7 +228,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} = []; @@ -260,7 +267,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 2a75da7de4..49f7ae4bee 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -48,7 +48,6 @@ can_ok( AddIssuingCharge AddRenewal AddReturn - GetBiblioIssues GetIssuingCharges GetOpenIssue GetRenewCount @@ -297,9 +296,6 @@ subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub { } }; -#Test GetBiblioIssues -is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); - #Test GetOpenIssue is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" ); is( GetOpenIssue(-1), undef, -- 2.39.5