From 8097c8e5479a7ab1f64434871254acb0d8a8007f Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Wed, 4 Oct 2017 16:50:26 -0600 Subject: [PATCH] Bug 18887: (follow-up) Fix null/empty behavior --- C4/Reserves.pm | 2 +- admin/smart-rules.pl | 4 ++-- installer/data/mysql/atomicupdate/bug_18887.perl | 4 ++-- koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 58c6a87b95..7325eb5ff9 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -416,7 +416,7 @@ sub CanItemBeReserved { rule_name => 'max_holds', } ); - if ( $rule ) { + if ( $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) { my $total_holds_count = Koha::Holds->search( { borrowernumber => $borrower->{borrowernumber} diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 4a9a577ad2..9cc4bb276d 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -234,7 +234,7 @@ elsif ($op eq "set-branch-defaults") { $holdallowed =~ s/\s//g; $holdallowed = undef if $holdallowed !~ /^\d+/; $max_holds =~ s/\s//g; - $max_holds = undef if $max_holds !~ /^\d+/; + $max_holds = '' if $max_holds !~ /^\d+/; if ($branch eq "*") { my $sth_search = $dbh->prepare("SELECT count(*) AS total @@ -290,7 +290,7 @@ elsif ($op eq "add-branch-cat") { $maxonsiteissueqty =~ s/\s//g; $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; $max_holds =~ s/\s//g; - $max_holds = undef if $max_holds !~ /^\d+/; + $max_holds = '' if $max_holds !~ /^\d+/; if ($branch eq "*") { if ($categorycode eq "*") { diff --git a/installer/data/mysql/atomicupdate/bug_18887.perl b/installer/data/mysql/atomicupdate/bug_18887.perl index 38610c9d44..07ee2d357f 100644 --- a/installer/data/mysql/atomicupdate/bug_18887.perl +++ b/installer/data/mysql/atomicupdate/bug_18887.perl @@ -20,12 +20,12 @@ if( CheckVersion( $DBversion ) ) { $dbh->do(q{ INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) - SELECT branchcode, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules + SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules }); $dbh->do(q{ INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) - SELECT NULL, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules + SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules }); $dbh->do(q{ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index ae4b4a1119..8f1c415fc8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -501,7 +501,7 @@ [% SET rule_value = CirculationRules.Get( branch_cat_rule_loo.branchcode, branch_cat_rule_loo.categorycode, branch_cat_rule_loo.itemtype, 'max_holds' ) %] - [% IF rule_value %] + [% IF rule_value.defined && rule_value != '' %] [% rule_value %] [% ELSE %] Unlimited -- 2.15.1