From 364991ed960f5110cacaadd3fb1771055c670b2b Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 23 Jul 2025 04:51:06 +0000 Subject: [PATCH] Bug 15516: (follow-up) fix count_holds() for CanBookBeReserved() This patch adds search_attrs to count_holds() since these get used with CanBookBeReserved. Test plan: 0. Apply the patch 1. prove t/db_dependent/Koha/Holds.t t/db_dependent/Reserves/HoldGroup.t t/db_dependent/Reserves.t --- C4/Reserves.pm | 2 +- Koha/Holds.pm | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 94ce0ffd2d6..99b12ff10eb 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -399,7 +399,7 @@ sub CanBookBeReserved { ] }, { join => ['item'] } - )->count; + ); return { status => '' } if defined $reservesallowed and $reservesallowed < $count + 1; diff --git a/Koha/Holds.pm b/Koha/Holds.pm index 62b3e0e8cf4..04092824ac4 100644 --- a/Koha/Holds.pm +++ b/Koha/Holds.pm @@ -217,13 +217,15 @@ Return the number of holds, where a hold group is counted as one hold. =cut sub count_holds { - my ( $self, $search_params ) = @_; - $search_params = {} if !$search_params; + my ( $self, $search_params, $search_attrs ) = @_; + $search_params = {} if !$search_params; + $search_attrs = {} if !$search_attrs; $search_params->{hold_group_id} = undef; - my $holds_without_group_count = $self->search($search_params)->count(); + my $holds_without_group_count = $self->search( $search_params, $search_attrs )->count(); $search_params->{hold_group_id} = { '!=', undef }; - my $hold_groups_count = $self->search( $search_params, { group_by => 'me.hold_group_id' } )->count(); + $search_attrs->{group_by} = 'me.hold_group_id'; + my $hold_groups_count = $self->search( $search_params, $search_attrs )->count(); return $holds_without_group_count + $hold_groups_count; } -- 2.39.5