From 7c809faba9e3a756374df5de82d6c98884cbe677 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jul 2014 13:39:07 +0200 Subject: [PATCH] Bug 12583: DelItem prototype - Remove $dbh Since C4::Context->dbh shares the DB handler, it's useless to pass it to routines. Test plan: Try to remove an item from the Koha interface. Verify that unit tests pass. Signed-off-by: Chris Cormack Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Acquisition.pm | 2 +- C4/Items.pm | 16 ++++++++-------- t/db_dependent/Items.t | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 7904cbe443..1a48926621 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1861,7 +1861,7 @@ sub DelOrder { $sth->execute( $bibnum, $ordernumber ); my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); foreach my $itemnumber (@itemnumbers){ - C4::Items::DelItem( $dbh, $bibnum, $itemnumber ); + C4::Items::DelItem( $bibnum, $itemnumber ); } return; } diff --git a/C4/Items.pm b/C4/Items.pm index 6ab04e3345..f644c75af1 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -632,18 +632,17 @@ sub ModDateLastSeen { =head2 DelItem - DelItem($dbh, $biblionumber, $itemnumber); + DelItem( $biblionumber, $itemnumber ); Exported function (core API) for deleting an item record in Koha. =cut sub DelItem { - my ( $dbh, $biblionumber, $itemnumber ) = @_; - + my ( $biblionumber, $itemnumber ) = @_; + # FIXME check the item has no current issues - - _koha_delete_item( $dbh, $itemnumber ); + _koha_delete_item( $itemnumber ); # get the MARC record my $record = GetMarcBiblio($biblionumber); @@ -2288,7 +2287,7 @@ sub DelItemCheck { } elsif ($countanalytics > 0){ $error = "linked_analytics"; } else { - DelItem($dbh, $biblionumber, $itemnumber); + DelItem($biblionumber, $itemnumber); return 1; } } @@ -2330,15 +2329,16 @@ sub _koha_modify_item { =head2 _koha_delete_item - _koha_delete_item( $dbh, $itemnum ); + _koha_delete_item( $itemnum ); Internal function to delete an item record from the koha tables =cut sub _koha_delete_item { - my ( $dbh, $itemnum ) = @_; + my ( $itemnum ) = @_; + my $dbh = C4::Context->dbh; # save the deleted item to deleteditems table my $sth = $dbh->prepare("SELECT * FROM items WHERE itemnumber=?"); $sth->execute($itemnum); diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index f5561fc5fa..7afdbec964 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -58,7 +58,7 @@ subtest 'General Add, Get and Del tests' => sub { cmp_ok($moditem->{'barcode'}, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->{'barcode'} . '.'); # Delete item. - DelItem($dbh, $bibnum, $itemnumber); + DelItem($bibnum, $itemnumber); my $getdeleted = GetItem($itemnumber); is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected."); -- 2.39.5