Bugzilla – Attachment 184209 Details for
Bug 40424
Handling query-in-body relies on wrong data structure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40424: Simplify existing code - preparation
Bug-40424-Simplify-existing-code---preparation.patch (text/plain), 2.70 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-07-17 15:01:30 UTC
(
hide
)
Description:
Bug 40424: Simplify existing code - preparation
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-07-17 15:01:30 UTC
Size:
2.70 KB
patch
obsolete
>From fe7cf590c2ebe3d355606f0781ca41edc773b8e9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 17 Jul 2025 11:34:14 -0300 >Subject: [PATCH] Bug 40424: Simplify existing code - preparation > >I wanted to isolate the changes for the query-in-body handling and it >made sense to refactor this dupicated code at the same time. So I add >this patch for tidying the area in preparation for the other part. > >Duplicated code gets simplified. > >To test: >1. Apply the unit tests patch >2. Run: > $ ktd --shell > k$ prove t/Koha/REST/Plugin/Query.t \ > t/db_dependent/api/v1/*.t \ > t/db_dependent/Koha/REST/Plugin/ >=> SUCCESS: Tests pass! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D >--- > Koha/REST/Plugin/Objects.pm | 26 +++++++++----------------- > 1 file changed, 9 insertions(+), 17 deletions(-) > >diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm >index 68d4c036243..753f3b8e6e5 100644 >--- a/Koha/REST/Plugin/Objects.pm >+++ b/Koha/REST/Plugin/Objects.pm >@@ -214,7 +214,10 @@ controller, and thus shouldn't be called twice in it. > ); > > my $query_params; >- if ( defined $reserved_params->{q} >+ >+ my $q_param = $reserved_params->{q}; >+ >+ if ( $q_param > || defined $reserved_params->{query} ) > { > >@@ -231,23 +234,12 @@ controller, and thus shouldn't be called twice in it. > push @query_params_array, $json->decode($query); > } > >- if ( ref( $reserved_params->{q} ) eq 'ARRAY' ) { >- >- # q is defined as multi => JSON::Validator generates an array >- foreach my $q ( @{ $reserved_params->{q} } ) { >- if ($q) { # skip if exists but is empty >- foreach my $qf ( @{$query_fixers} ) { >- $q = $qf->($q); >- } >- push @query_params_array, $json->decode($q); >- } >- } >- } else { >+ # The q parameter can be an array if multiple passed >+ $q_param = [$q_param] >+ unless ref($q_param) eq 'ARRAY'; > >- # objects.search called outside OpenAPI context >- # might be a hashref >- if ( $reserved_params->{q} ) { >- my $q = $reserved_params->{q}; >+ foreach my $q ( @{$q_param} ) { >+ if ($q) { # skip if exists but is empty > foreach my $qf ( @{$query_fixers} ) { > $q = $qf->($q); > } >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40424
:
184208
|
184209
|
184210
|
184218
|
184219
|
184220
|
184554
|
184555
|
184556