]> git.koha-community.org Git - koha.git/commit
Bug 33556: Avoid relying on $c->validation
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 29 May 2023 15:10:51 +0000 (12:10 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 8 Aug 2023 06:05:46 +0000 (20:05 -1000)
commit335681df52b7b74773c26432133c53ff4f4fe2e4
tree291f0c27ff65827de9675f7619b414bf4ec419d5
parent7796cf1e30fe9e77c313b0a4feb485a446c3afa8
Bug 33556: Avoid relying on $c->validation

Talking to the OpenAPI plugin maintainer, he mentioned the use of $c->validation->output should be avoided as the plugin is not designed to have a stable behavior there, and he even thought of just removing the method.

That method returns an internal data structure the plugin uses to validate things, and then updates the request itself.

Take the following example:

GET /patrons/123
x-koha-embed: checkouts,library

without the OpenAPI plugin, requesting the header like this:

$c->req->headers->header('x-koha-embed')

would return a scalar, the string 'checkouts,library'.

When using the plugin, and with `x-koha-embed` being defined as collectionFormat: csv, that header is entirely replaced by an arrayref.

That's how the plugin works and how it is expected to be used. So we need to replace the uses of $c->validation format, with normal Mojo usage to avoid future headaches.

This patch changes:
* $c->validation->param => $c->param
* $c->validation->param('body') => $c->req->json

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/*.t
=> SUCCESS: Tests pass!
2. Apply this patches
3. Repeat 1
=> SUCCESS: Tests still pass!
4. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 95af4c9de18ebbb686ec2b1291dbf0fa980c9450)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
39 files changed:
Koha/REST/V1/Acquisitions/Orders.pm
Koha/REST/V1/Acquisitions/Vendors.pm
Koha/REST/V1/AdvancedEditorMacro.pm
Koha/REST/V1/ArticleRequests.pm
Koha/REST/V1/Auth/Identity/Provider/Domains.pm
Koha/REST/V1/Auth/Identity/Providers.pm
Koha/REST/V1/Auth/Password.pm
Koha/REST/V1/AuthorisedValues.pm
Koha/REST/V1/Authorities.pm
Koha/REST/V1/BackgroundJobs.pm
Koha/REST/V1/Biblios.pm
Koha/REST/V1/Biblios/ItemGroups.pm
Koha/REST/V1/Biblios/ItemGroups/Items.pm
Koha/REST/V1/CashRegisters/Cashups.pm
Koha/REST/V1/Checkouts.pm
Koha/REST/V1/Cities.pm
Koha/REST/V1/Clubs/Holds.pm
Koha/REST/V1/Config/SMTP/Servers.pm
Koha/REST/V1/Holds.pm
Koha/REST/V1/Illbackends.pm
Koha/REST/V1/ImportBatchProfiles.pm
Koha/REST/V1/ImportRecordMatches.pm
Koha/REST/V1/Items.pm
Koha/REST/V1/Libraries.pm
Koha/REST/V1/OAuth.pm
Koha/REST/V1/Patrons.pm
Koha/REST/V1/Patrons/Account.pm
Koha/REST/V1/Patrons/Attributes.pm
Koha/REST/V1/Patrons/Holds.pm
Koha/REST/V1/Patrons/Password.pm
Koha/REST/V1/Patrons/Password/Expiration.pm
Koha/REST/V1/Quotes.pm
Koha/REST/V1/ReturnClaims.pm
Koha/REST/V1/SearchFilter.pm
Koha/REST/V1/Stage.pm
Koha/REST/V1/Suggestions.pm
Koha/REST/V1/Tickets.pm
Koha/REST/V1/TransferLimits.pm
Koha/REST/V1/TwoFactorAuth.pm