Bug 37902: Make sure filtered_params are converted

Previously we only adjusted the attributes that were passed directly,
not the ones in 'q' (which is the recommended way now)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-09-12 10:41:18 +02:00 committed by Katrin Fischer
parent aa70b472ff
commit e36db00fa1
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 15 additions and 17 deletions

View File

@ -209,20 +209,10 @@ controller, and thus shouldn't be called twice in it.
}
);
# Call the to_model function by reference, if defined
if ( defined $filtered_params ) {
# Apply the mapping function to the passed params
$filtered_params =
$result_set->attributes_from_api($filtered_params);
$filtered_params =
$c->build_query_params( $filtered_params, $reserved_params );
}
my $query_params;
if ( defined $reserved_params->{q}
|| defined $reserved_params->{query} )
{
$filtered_params //= {};
my @query_params_array;
@ -261,18 +251,12 @@ controller, and thus shouldn't be called twice in it.
}
}
my $query_params;
if ( scalar(@query_params_array) > 1 ) {
$query_params = { '-and' => \@query_params_array };
}
else {
$query_params = $query_params_array[0];
}
$filtered_params =
$c->merge_q_params( $filtered_params, $query_params,
$result_set );
}
# request sequence id (i.e. 'draw' Datatables parameter)
@ -287,6 +271,20 @@ controller, and thus shouldn't be called twice in it.
$c->stash('koha.pagination.base_total' => $result_set->count);
$c->stash('koha.pagination.query_params' => $args);
# Apply the mapping function to the passed params
if ( defined $filtered_params ) {
$filtered_params =
$c->build_query_params( $filtered_params, $reserved_params );
}
$filtered_params =
$c->merge_q_params( $filtered_params, $query_params,
$result_set );
$filtered_params =
$result_set->attributes_from_api($filtered_params);
$c->dbic_validate_operators( { filtered_params => $filtered_params } );
# Generate the resultset