Bugzilla – Attachment 132139 Details for
Bug 30165
Several q parameters break the filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[OPTION 2] Bug 30165: (follow-up) Allow objects.search usage outside OpenAPI
OPTION-2-Bug-30165-follow-up-Allow-objectssearch-u.patch (text/plain), 2.32 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-03-24 12:56:00 UTC
(
hide
)
Description:
[OPTION 2] Bug 30165: (follow-up) Allow objects.search usage outside OpenAPI
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-03-24 12:56:00 UTC
Size:
2.32 KB
patch
obsolete
>From df3316eaad75efbce137707d34ee29213dd25907 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 24 Mar 2022 09:52:04 -0300 >Subject: [PATCH] [OPTION 2] Bug 30165: (follow-up) Allow objects.search usage > outside OpenAPI > >Our objects.search helper is written for being used in our API >controllers, which get their query parameters processed by the OpenAPI >plugin, using JSON::Validator. > >Particularly, the 'q' parameter is defined as 'multi' on our spec, which >means objects.search always gets it as an arrayref. > >As the Objects.t tests are not using the OpenAPI plugin, a hashref is >generated as only one q= is being passed. This patch adds an extra >validation on objects.search, for the non-arrayref use case and does the >right thing. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t >=> FAIL: Tests fail! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/Plugin/Objects.pm | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm >index 6a94dac11c..86c1d297e0 100644 >--- a/Koha/REST/Plugin/Objects.pm >+++ b/Koha/REST/Plugin/Objects.pm >@@ -152,10 +152,18 @@ shouldn't be called twice in it. > > my $json = JSON->new; > >- # q is defined as multi => JSON::Validator generates an array >- foreach my $q ( @{ $reserved_params->{q} } ) { >- push @query_params_array, $json->decode($q) >- if $q; # skip if exists but is empty >+ if ( ref($reserved_params->{q}) eq 'ARRAY' ) { >+ # q is defined as multi => JSON::Validator generates an array >+ foreach my $q ( @{ $reserved_params->{q} } ) { >+ push @query_params_array, $json->decode($q) >+ if $q; # skip if exists but is empty >+ } >+ } >+ else { >+ # objects.search called outside OpenAPI context >+ # might be a hashref >+ push @query_params_array, $json->decode($reserved_params->{q}) >+ if $reserved_params->{q}; > } > > push @query_params_array, >-- >2.32.0
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 30165
:
131111
|
131706
|
131707
|
131759
|
131760
|
131761
|
131803
|
131804
|
131805
|
131821
|
131822
|
131823
|
132138
| 132139