From b27b1efcb10c95f0774cdec467bbc1a2c619e5fa Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 22 Jan 2026 15:32:39 +0100 Subject: [PATCH] Bug 41602: Allow _status to be in nested structure This patch allows _status to be in a nested structure. Cannot be combined in all the possible ways, but at least it should fix the UI. Test plan: Use the filters on the holdings table and confirm that you can combine the status with other filters. --- Koha/Items.pm | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 668d5f4bacc..062ade8763a 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -659,9 +659,42 @@ Filters items based on the specified status. =cut +sub _extract_custom_attrs { + my ($params) = @_; + my %custom_attrs; + my $clean_params = _process_params( $params, \%custom_attrs ); + return ( \%custom_attrs, $clean_params ); +} + +sub _process_params { + my ( $params, $custom_attrs ) = @_; + + return $params unless ref $params; + + if ( ref $params eq 'HASH' ) { + my %clean; + for my $key ( keys %$params ) { + if ( $key =~ /^_(.+)/ ) { + $custom_attrs->{$key} = $params->{$key}; + } else { + $clean{$key} = _process_params( $params->{$key}, $custom_attrs ); + } + } + return \%clean; + } elsif ( ref $params eq 'ARRAY' ) { + return [ map { _process_params( $_, $custom_attrs ) } @$params ]; + } else { + return $params; + } +} + sub search { my ( $self, $params, $attributes ) = @_; - my $status = ( $params && ref($params) eq 'HASH' ) ? delete $params->{_status} : undef; + + my ( $custom_attrs, $clean_params ) = _extract_custom_attrs($params); + $params = $clean_params; + + my $status = $custom_attrs->{_status}; if ($status) { if ( $status eq 'checked_out' ) { $self = $self->filter_by_checked_out( { onsite_checkout => 0 } ); -- 2.43.0