Bug 23233: Remove use of AllowItemsOnHoldCheckout from Koha::Item::has_pending_hold, it can cause false data to be returned

Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit dc769fd065)
This commit is contained in:
Kyle M Hall 2019-07-01 07:19:33 -04:00 committed by Lucas Gass
parent 366a80fb5b
commit 169dd65ec7
2 changed files with 2 additions and 6 deletions

View File

@ -365,7 +365,7 @@ This method checks the tmp_holdsqueue to see if this item has been selected for
sub has_pending_hold {
my ( $self ) = @_;
my $pending_hold = $self->_result->tmp_holdsqueues;
return !C4::Context->preference('AllowItemsOnHoldCheckoutSIP') && $pending_hold->count ? 1: 0;
return $pending_hold->count ? 1: 0;
}
=head2 Internal methods

View File

@ -64,7 +64,7 @@ subtest 'hidden_in_opac() tests' => sub {
subtest 'has_pending_hold() tests' => sub {
plan tests => 3;
plan tests => 2;
$schema->storage->txn_begin;
@ -73,12 +73,8 @@ subtest 'has_pending_hold() tests' => sub {
my $itemnumber = $item->itemnumber;
# disable AllowItemsOnHoldCheckout as it ignores pending holds
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
$dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)");
ok( $item->has_pending_hold, "Yes, we have a pending hold");
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
ok( !$item->has_pending_hold, "We don't consider a pending hold if hold items can be checked out");
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
$dbh->do("DELETE FROM tmp_holdsqueue WHERE itemnumber=$itemnumber");
ok( !$item->has_pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue");
};