From f8832b0dc275df3ba1cc26e31086ac73bbe14cda Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 4 Feb 2026 17:45:19 +0000 Subject: [PATCH] Bug 28530: (QA follow-up) Use DBIC in controller Signed-off-by: Martin Renvoize --- admin/float_limits.pl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/admin/float_limits.pl b/admin/float_limits.pl index e68129eb4a9..6d1f820a3e6 100755 --- a/admin/float_limits.pl +++ b/admin/float_limits.pl @@ -48,21 +48,25 @@ if ( $op eq 'cud-set_float_limits' ) { $schema->txn_do( sub { - $schema->storage->dbh->do("DELETE FROM library_float_limits"); + # Clear all existing float limits using DBIC + Koha::Library::FloatLimits->delete; foreach my $branch (@branches) { foreach my $itemtype (@itemtypes) { my $branchcode = $branch->id; my $itype = $itemtype->id; my $limit = $input->param( "limit_" . $branchcode . "_" . $itype ); - Koha::Library::FloatLimit->new( - { - branchcode => $branchcode, - itemtype => $itype, - float_limit => $limit, - } - )->store() - if $limit ne q{}; # update or insert + + # Validate: must be empty or a non-negative integer + if ( $limit ne q{} && $limit =~ /^\d+$/ && $limit >= 0 ) { + Koha::Library::FloatLimit->new( + { + branchcode => $branchcode, + itemtype => $itype, + float_limit => $limit, + } + )->store(); # update or insert + } } } $template->param( float_limits_updated => 1 ); -- 2.52.0