From acbead2c0ac6448bdbd9957f423173bb55714baf 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. --- 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 28b52f5..32bc48c 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1855,7 +1855,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 6ab04e3..f644c75 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 f5561fc..7afdbec 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.0.0.rc2