From f2b20a13615babce62ef5d8ed4f1a9e99ba7a5b2 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 --- 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 2960c30bb9..e866d02ae1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -98,7 +98,6 @@ BEGIN { &GetIssuingCharges &GetBranchBorrowerCircRule &GetBranchItemRule - &GetBiblioIssues &GetOpenIssue &CheckIfIssuedToPatron &IsItemIssued @@ -2644,50 +2643,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 da37e936ae..30a03bceb2 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} = []; @@ -274,7 +281,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 3fbf46c590..6383c7431e 100755 --- 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.11.0