Lines 138-155
shouldn't be called twice in it.
Link Here
|
138 |
$filtered_params = $c->build_query_params( $filtered_params, $reserved_params ); |
138 |
$filtered_params = $c->build_query_params( $filtered_params, $reserved_params ); |
139 |
} |
139 |
} |
140 |
|
140 |
|
141 |
if( defined $reserved_params->{q} || defined $reserved_params->{query} || defined $reserved_params->{'x-koha-query'}) { |
141 |
if ( defined $reserved_params->{q} |
142 |
$filtered_params //={}; |
142 |
|| defined $reserved_params->{query} |
|
|
143 |
|| defined $reserved_params->{'x-koha-query'} ) |
144 |
{ |
145 |
$filtered_params //= {}; |
146 |
|
143 |
my @query_params_array; |
147 |
my @query_params_array; |
144 |
my $query_params; |
148 |
|
145 |
push @query_params_array, $reserved_params->{query} if defined $reserved_params->{query}; |
149 |
# query in request body, JSON::Validator already decoded it |
|
|
150 |
push @query_params_array, $reserved_params->{query} |
151 |
if defined $reserved_params->{query}; |
152 |
|
146 |
my $json = JSON->new; |
153 |
my $json = JSON->new; |
147 |
push @query_params_array, $json->decode($reserved_params->{q}) if defined $reserved_params->{q}; |
|
|
148 |
push @query_params_array, $json->decode($reserved_params->{'x-koha-query'}) if defined $reserved_params->{'x-koha-query'}; |
149 |
|
154 |
|
150 |
if(scalar(@query_params_array) > 1) { |
155 |
# q is defined as multi => JSON::Validator generates an array |
151 |
$query_params = {'-and' => \@query_params_array}; |
156 |
foreach my $q ( @{ $reserved_params->{q} } ) { |
152 |
} else { |
157 |
push @query_params_array, $json->decode($q) |
|
|
158 |
if $q; # skip if exists but is empty |
159 |
} |
160 |
|
161 |
push @query_params_array, |
162 |
$json->decode( $reserved_params->{'x-koha-query'} ) |
163 |
if defined $reserved_params->{'x-koha-query'}; |
164 |
|
165 |
my $query_params; |
166 |
|
167 |
if ( scalar(@query_params_array) > 1 ) { |
168 |
$query_params = { '-and' => \@query_params_array }; |
169 |
} |
170 |
else { |
153 |
$query_params = $query_params_array[0]; |
171 |
$query_params = $query_params_array[0]; |
154 |
} |
172 |
} |
155 |
|
173 |
|