View | Details | Raw Unified | Return to bug 35899
Collapse All | Expand All

(-)a/C4/HoldsQueue.pm (-1 / +24 lines)
Lines 29-34 use Koha::Hold::HoldsQueueItems; Link Here
29
use Koha::Items;
29
use Koha::Items;
30
use Koha::Libraries;
30
use Koha::Libraries;
31
use Koha::Patrons;
31
use Koha::Patrons;
32
use Koha::Cache::Memory::Lite;
32
33
33
use List::Util qw( shuffle );
34
use List::Util qw( shuffle );
34
use List::MoreUtils qw( any );
35
use List::MoreUtils qw( any );
Lines 297-302 to fill a hold request if and only if: Link Here
297
298
298
=cut
299
=cut
299
300
301
sub _getBranchItemRule {
302
    my ( $branchcode, $itemtype ) = @_;
303
304
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
305
    my $key =
306
          '_getBranchItemRule:'
307
        . (defined $branchcode ? $branchcode : '*') . ':'
308
        . (defined $itemtype   ? $itemtype   : '*');
309
310
    my $result = $memory_cache->get_from_cache($key);
311
312
    if ( defined $result ) {
313
        return $result;
314
    }
315
316
    $result = C4::Circulation::GetBranchItemRule( $branchcode, $itemtype );
317
318
    $memory_cache->set_in_cache( $key, $result );
319
320
    return $result;
321
}
322
300
sub GetItemsAvailableToFillHoldRequestsForBib {
323
sub GetItemsAvailableToFillHoldRequestsForBib {
301
    my ($biblionumber, $branches_to_use) = @_;
324
    my ($biblionumber, $branches_to_use) = @_;
302
325
Lines 341-347 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
341
364
342
    my $itm = $sth->fetchall_arrayref({});
365
    my $itm = $sth->fetchall_arrayref({});
343
    return [ grep {
366
    return [ grep {
344
        my $rule = C4::Circulation::GetBranchItemRule($_->{homebranch}, $_->{itype});
367
        my $rule = _getBranchItemRule($_->{homebranch}, $_->{itype});
345
        $_->{holdallowed} = $rule->{holdallowed};
368
        $_->{holdallowed} = $rule->{holdallowed};
346
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
369
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
347
    } @{$itm} ];
370
    } @{$itm} ];
(-)a/t/db_dependent/HoldsQueue.t (-1 / +13 lines)
Lines 20-25 use Koha::DateUtils qw( dt_from_string ); Link Here
20
use Koha::Items;
20
use Koha::Items;
21
use Koha::Holds;
21
use Koha::Holds;
22
use Koha::CirculationRules;
22
use Koha::CirculationRules;
23
use Koha::Cache::Memory::Lite;
23
24
24
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
25
use t::lib::Mocks;
26
use t::lib::Mocks;
Lines 35-40 my $schema = Koha::Database->schema; Link Here
35
$schema->storage->txn_begin;
36
$schema->storage->txn_begin;
36
my $dbh = C4::Context->dbh;
37
my $dbh = C4::Context->dbh;
37
$dbh->do("DELETE FROM circulation_rules");
38
$dbh->do("DELETE FROM circulation_rules");
39
Koha::Cache::Memory::Lite->flush();
38
40
39
my $builder = t::lib::TestBuilder->new;
41
my $builder = t::lib::TestBuilder->new;
40
42
Lines 186-191 $schema->txn_begin; Link Here
186
188
187
# Clear out existing rules relating to holdallowed
189
# Clear out existing rules relating to holdallowed
188
$dbh->do("DELETE FROM circulation_rules");
190
$dbh->do("DELETE FROM circulation_rules");
191
Koha::Cache::Memory::Lite->flush();
189
192
190
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
193
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0);
191
194
Lines 306-311 $sth->execute( $borrower3->{borrowernumber}, $biblionumber, $branchcodes[0], 3 ) Link Here
306
my $holds_queue;
309
my $holds_queue;
307
310
308
$dbh->do("DELETE FROM circulation_rules");
311
$dbh->do("DELETE FROM circulation_rules");
312
Koha::Cache::Memory::Lite->flush();
309
Koha::CirculationRules->set_rule(
313
Koha::CirculationRules->set_rule(
310
    {
314
    {
311
        rule_name    => 'holdallowed',
315
        rule_name    => 'holdallowed',
Lines 343-348 is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed librari Link Here
343
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
347
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
344
348
345
$dbh->do("DELETE FROM circulation_rules");
349
$dbh->do("DELETE FROM circulation_rules");
350
Koha::Cache::Memory::Lite->flush();
346
Koha::CirculationRules->set_rule(
351
Koha::CirculationRules->set_rule(
347
    {
352
    {
348
        rule_name    => 'holdallowed',
353
        rule_name    => 'holdallowed',
Lines 370-375 t::lib::Mocks::mock_preference( 'HoldsQueueSkipClosed', 0 ); Link Here
370
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
375
t::lib::Mocks::mock_preference('LocalHoldsPriority', 1);
371
376
372
$dbh->do("DELETE FROM circulation_rules");
377
$dbh->do("DELETE FROM circulation_rules");
378
Koha::Cache::Memory::Lite->flush();
373
Koha::CirculationRules->set_rule(
379
Koha::CirculationRules->set_rule(
374
    {
380
    {
375
        rule_name    => 'holdallowed',
381
        rule_name    => 'holdallowed',
Lines 646-651 $dbh->do(" Link Here
646
652
647
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
653
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
648
$dbh->do("DELETE FROM circulation_rules");
654
$dbh->do("DELETE FROM circulation_rules");
655
Koha::Cache::Memory::Lite->flush();
649
Koha::CirculationRules->set_rules(
656
Koha::CirculationRules->set_rules(
650
    {
657
    {
651
        branchcode   => undef,
658
        branchcode   => undef,
Lines 707-712 Koha::Holds->find( $reserve_id )->cancel; Link Here
707
714
708
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
715
# With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch
709
$dbh->do("DELETE FROM circulation_rules");
716
$dbh->do("DELETE FROM circulation_rules");
717
Koha::Cache::Memory::Lite->flush();
710
Koha::CirculationRules->set_rules(
718
Koha::CirculationRules->set_rules(
711
    {
719
    {
712
        branchcode   => undef,
720
        branchcode   => undef,
Lines 765-770 Koha::Holds->find( $reserve_id )->cancel; Link Here
765
773
766
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
774
# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch
767
$dbh->do("DELETE FROM circulation_rules");
775
$dbh->do("DELETE FROM circulation_rules");
776
Koha::Cache::Memory::Lite->flush();
768
Koha::CirculationRules->set_rules(
777
Koha::CirculationRules->set_rules(
769
    {
778
    {
770
        branchcode   => undef,
779
        branchcode   => undef,
Lines 856-861 $dbh->do(" Link Here
856
865
857
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
866
# With hold_fulfillment_policy = homebranch, hold should only be picked up if pickup branch = homebranch
858
$dbh->do("DELETE FROM circulation_rules");
867
$dbh->do("DELETE FROM circulation_rules");
868
Koha::Cache::Memory::Lite->flush();
859
Koha::CirculationRules->set_rules(
869
Koha::CirculationRules->set_rules(
860
    {
870
    {
861
        branchcode   => undef,
871
        branchcode   => undef,
Lines 1207-1212 subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue Link Here
1207
    $dbh->do("DELETE FROM hold_fill_targets");
1217
    $dbh->do("DELETE FROM hold_fill_targets");
1208
    $dbh->do("DELETE FROM reserves");
1218
    $dbh->do("DELETE FROM reserves");
1209
    $dbh->do("DELETE FROM circulation_rules");
1219
    $dbh->do("DELETE FROM circulation_rules");
1220
    Koha::Cache::Memory::Lite->flush();
1210
    Koha::Biblios->delete();
1221
    Koha::Biblios->delete();
1211
1222
1212
    t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 );
1223
    t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 );
Lines 1274-1279 subtest "Item level holds info is preserved (Bug 25738)" => sub { Link Here
1274
    $dbh->do("DELETE FROM hold_fill_targets");
1285
    $dbh->do("DELETE FROM hold_fill_targets");
1275
    $dbh->do("DELETE FROM reserves");
1286
    $dbh->do("DELETE FROM reserves");
1276
    $dbh->do("DELETE FROM circulation_rules");
1287
    $dbh->do("DELETE FROM circulation_rules");
1288
    Koha::Cache::Memory::Lite->flush();
1277
1289
1278
    my $library  = $builder->build_object({ class => 'Koha::Libraries' });
1290
    my $library  = $builder->build_object({ class => 'Koha::Libraries' });
1279
    my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} });
1291
    my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} });
Lines 1482-1487 subtest "Test item group holds" => sub { Link Here
1482
    $dbh->do("DELETE FROM hold_fill_targets");
1494
    $dbh->do("DELETE FROM hold_fill_targets");
1483
    $dbh->do("DELETE FROM reserves");
1495
    $dbh->do("DELETE FROM reserves");
1484
    $dbh->do("DELETE FROM circulation_rules");
1496
    $dbh->do("DELETE FROM circulation_rules");
1497
    Koha::Cache::Memory::Lite->flush();
1485
1498
1486
    t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
1499
    t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0);
1487
    t::lib::Mocks::mock_preference('LocalHoldsPriority', 0);
1500
    t::lib::Mocks::mock_preference('LocalHoldsPriority', 0);
1488
- 

Return to bug 35899