From aa5418dca6ae20e70e92ecf662a1f5b83c86cd3e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 1 Jul 2019 08:56:09 -0400 Subject: [PATCH] Bug 23233: Remove use of AllowItemsOnHoldCheckout from C4::Items::GetItemsInfo MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson --- C4/Items.pm | 9 +++------ t/db_dependent/Items.t | 10 ++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index c5d248a72f..4f6a587db2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -948,10 +948,8 @@ sub GetItemsInfo { holding.branchcode, holding.branchname, holding.opac_info as holding_branch_opac_info, - home.opac_info as home_branch_opac_info - "; - $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS has_pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckoutSIP'); - $query .= " + home.opac_info as home_branch_opac_info, + IF(tmp_holdsqueue.itemnumber,1,0) AS has_pending_hold FROM items LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode LEFT JOIN branches AS home ON items.homebranch=home.branchcode @@ -963,9 +961,8 @@ sub GetItemsInfo { LEFT JOIN serial USING (serialid) LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); - $query .= " - LEFT JOIN tmp_holdsqueue USING (itemnumber)" if !C4::Context->preference('AllowItemsOnHoldCheckoutSIP'); $query .= q| + LEFT JOIN tmp_holdsqueue USING (itemnumber) LEFT JOIN localization ON itemtypes.itemtype = localization.code AND localization.entity = 'itemtypes' AND localization.lang = ? diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index bbed0436b6..401c881735 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -313,18 +313,16 @@ subtest 'GetItemsInfo tests' => sub { is( $results[0]->{ restrictedvalueopac }, "Restricted Access OPAC", 'GetItemsInfo returns a restricted value description (OPAC)' ); - t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 ); #place item into holds queue my $dbh = C4::Context->dbh; + @results = GetItemsInfo( $biblio->biblionumber ); + is( $results[0]->{ has_pending_hold }, "0", + 'Hold not marked as pending/unavailable if nothing in tmp_holdsqueue for item' ); + $dbh->do(q{INSERT INTO tmp_holdsqueue (biblionumber, itemnumber, surname, borrowernumber ) VALUES (?, ?, "Zorro", 42)}, undef, $item_bibnum, $itemnumber); @results = GetItemsInfo( $biblio->biblionumber ); is( $results[0]->{ has_pending_hold }, "1", 'Hold marked as pending/unavailable if not AllowItemsOnHoldCheckout' ); - t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 ); - @results = GetItemsInfo( $biblio->biblionumber ); - is( $results[0]->{ has_pending_hold }, undef, - 'Hold not marked as pending/unavailable if AllowItemsOnHoldCheckout' ); - $schema->storage->txn_rollback; }; -- 2.39.5