Bugzilla – Attachment 78683 Details for
Bug 18887
Introduce new table 'circulation_rules', use for 'max_holds' rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18887: Insert undef instead of '*'
Bug-18887-Insert-undef-instead-of-.patch (text/plain), 3.49 KB, created by
Jonathan Druart
on 2018-09-14 17:51:36 UTC
(
hide
)
Description:
Bug 18887: Insert undef instead of '*'
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-09-14 17:51:36 UTC
Size:
3.49 KB
patch
obsolete
>From 67fef4da5caae8f224d4e79a4442f17bb5c10805 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 24 Jul 2018 11:04:35 -0300 >Subject: [PATCH] Bug 18887: Insert undef instead of '*' > >Koha::CirculationRules->get_effective_rule will become the method to >call to retrieve a specific rule, we should start using it when >possible. > >Moreover undef could replace '*' to mean 'any', that way we will be able >to add FK on circulation_rules > >TODO: Add more tests >--- > C4/Reserves.pm | 11 +---------- > Koha/CirculationRules.pm | 9 ++++++--- > admin/smart-rules.pl | 4 ++-- > 3 files changed, 9 insertions(+), 15 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 22f6dda14a..3271030bae 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -413,19 +413,10 @@ sub CanItemBeReserved { > } > > # Now we need to check hold limits by patron category >- my $rule = Koha::CirculationRules->find( >+ my $rule = Koha::CirculationRules->get_effective_rule( > { > categorycode => $borrower->{categorycode}, > branchcode => $branchcode, >- itemtype => undef, >- rule_name => 'max_holds', >- } >- ); >- $rule ||= Koha::CirculationRules->find( >- { >- categorycode => $borrower->{categorycode}, >- branchcode => undef,, >- itemtype => undef, > rule_name => 'max_holds', > } > ); >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 054eb00858..76dc63d8cf 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -53,9 +53,9 @@ sub get_effective_rule { > my $search_params; > $search_params->{rule_name} = $rule_name; > >- $search_params->{categorycode} = defined $categorycode ? { 'in' => [ $categorycode, '*' ] } : undef; >- $search_params->{itemtype} = defined $itemtype ? { 'in' => [ $itemtype, '*' ] } : undef; >- $search_params->{branchcode} = defined $branchcode ? { 'in' => [ $branchcode, '*' ] } : undef; >+ $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef; >+ $search_params->{itemtype} = defined $itemtype ? [ $itemtype, undef ] : undef; >+ $search_params->{branchcode} = defined $branchcode ? [ $branchcode, undef ] : undef; > > my $rule = $self->search( > $search_params, >@@ -94,6 +94,9 @@ sub set_rule { > my $rule_name = $params->{rule_name}; > my $rule_value = $params->{rule_value}; > >+ for my $v ( $branchcode, $categorycode, $itemtype ) { >+ $v = undef if $v and $v eq '*'; >+ } > my $rule = $self->search( > { > rule_name => $rule_name, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index ac3f46e0b8..bdeee64e01 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -271,7 +271,7 @@ elsif ($op eq "set-branch-defaults") { > Koha::CirculationRules->set_rule( > { > branchcode => $branch, >- categorycode => '*', >+ categorycode => undef, > itemtype => undef, > rule_name => 'max_holds', > rule_value => $max_holds, >@@ -348,7 +348,7 @@ elsif ($op eq "add-branch-cat") { > > Koha::CirculationRules->set_rule( > { >- branchcode => '*', >+ branchcode => undef, > categorycode => $categorycode, > itemtype => undef, > rule_name => 'max_holds', >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18887
:
65233
|
65234
|
65235
|
65236
|
65237
|
67620
|
70986
|
70987
|
70988
|
70989
|
70990
|
70991
|
71031
|
71042
|
72218
|
72219
|
72220
|
72221
|
72222
|
72223
|
72224
|
77080
|
77081
|
77082
|
77083
|
77084
|
77085
|
77086
|
77087
|
77207
|
77208
|
77209
|
77210
|
77211
|
77212
|
77213
|
77214
|
77215
|
77218
|
77238
|
77649
|
77650
|
77651
|
77652
|
77653
|
77654
|
77655
|
77656
|
77657
|
77658
|
77659
|
78346
|
78347
|
78348
|
78349
|
78350
|
78351
|
78352
|
78353
|
78354
|
78355
|
78356
|
78674
|
78675
|
78676
|
78677
|
78678
|
78679
|
78680
|
78681
|
78682
|
78683
|
78684
|
78743
|
78744
|
78745
|
78746
|
78747
|
78748
|
78749
|
78750
|
78751
|
78752
|
78753
|
78879
|
79119
|
79626
|
79627
|
79628
|
79629
|
79630
|
79631
|
79632
|
79633
|
79634
|
79635
|
79636
|
79637
|
79638
|
79639
|
79640
|
79641
|
79761
|
79762
|
79763
|
79764
|
79765
|
79766
|
79767
|
79768
|
79769
|
79770
|
79771
|
79772
|
79773
|
79774
|
79775
|
79776
|
79778
|
79891