Bug 16819: C4::Members::DelMember should use Koha::Holds to delete holds

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 <hector.hecaxmmx@gmail.com>
All tests pass successfully

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2016-06-28 10:18:48 -03:00 committed by Kyle M Hall
parent 13bf3686c5
commit b7f15db41a

View file

@ -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;