From fa4d6a05efab1995defde1d4e8d75f0df4689d39 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 28 Jun 2016 10:18:48 -0300 Subject: [PATCH] Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch makes C4::Members::DelMember proprely use Koha::Holds to delete holds. This is important as holds actions are started to be logged. To reproduce: - Apply the patch - Run: $ prove t/db_dependent/Members.t => SUCCESS: Tests pass - Sign off :-D Sponsored-by: NEKLS Signed-off-by: Hector Castro All tests pass successfully Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit b7f15db41ae83654387a2191fa72bde60450b0b0) Signed-off-by: Frédéric Demians --- C4/Members.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 383799d5d1..4ca2f91dc0 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -41,6 +41,7 @@ use Koha::Patron::Debarments qw(IsDebarred); use Text::Unaccent qw( unac_string ); use Koha::AuthUtils qw(hash_password); use Koha::Database; +use Koha::Holds; use Koha::List::Patron; our (@ISA,@EXPORT,@EXPORT_OK,$debug); @@ -1660,18 +1661,16 @@ sub DelMember { my $borrowernumber = shift; #warn "in delmember with $borrowernumber"; return unless $borrowernumber; # borrowernumber is mandatory. + # Delete Patron's holds + my @holds = Koha::Holds->search({ borrowernumber => $borrowernumber }); + map { $_->delete } @holds; - my $query = qq|DELETE - FROM reserves - WHERE borrowernumber=?|; - my $sth = $dbh->prepare($query); - $sth->execute($borrowernumber); - $query = " + my $query = " DELETE FROM borrowers WHERE borrowernumber = ? "; - $sth = $dbh->prepare($query); + my $sth = $dbh->prepare($query); $sth->execute($borrowernumber); logaction("MEMBERS", "DELETE", $borrowernumber, "") if C4::Context->preference("BorrowersLog"); return $sth->rows; -- 2.39.5