Bugzilla – Attachment 182669 Details for
Bug 39944
Metadata should be trimmed before creating an ILL request
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39944: Trim form params
Bug-39944-Trim-form-params.patch (text/plain), 2.09 KB, created by
Pedro Amorim
on 2025-05-20 12:44:22 UTC
(
hide
)
Description:
Bug 39944: Trim form params
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-05-20 12:44:22 UTC
Size:
2.09 KB
patch
obsolete
>From 50e5d6edae5711b767c4e40a47c8a381a88b8392 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Tue, 20 May 2025 12:37:54 +0000 >Subject: [PATCH] Bug 39944: Trim form params > >Test plan, ktd, before applying patch: >1) Enable ILLModule sys pref and create a new ILL request: > <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard >2) Pick type 'journal article' and enter ' 123' to DOI (notice the leading white space) >3) Enter a cardnumber and a library. Click 'Create'. >4) Run the following SQL query (koha-mysql kohadev): > $ SELECT * from illrequestattributes where illrequest_id = '<put your request ID here>' and type ='doi'; >5) Notice the value is saved with the leading whitespace. Apply patch. Repeat. Notice it no longer saves with the leading white space. > >Sponsored-by: NHS England >--- > Koha/ILL/Request.pm | 24 ++++++++++++++++++++++++ > ill/ill-requests.pl | 1 + > 2 files changed, 25 insertions(+) > >diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm >index 9b151e3924c..d88c327e2f9 100644 >--- a/Koha/ILL/Request.pm >+++ b/Koha/ILL/Request.pm >@@ -2298,6 +2298,30 @@ sub can_patron_place_ill_in_opac { > return 1; > } > >+=head3 trim_form_params >+ >+ my $params = trim_form_params($params); >+ >+ Trims $params. Needed to ensure submitted data is not saved with leading or trailing white spaces: >+ >+ This: >+ { >+ 'doi' => ' 123', >+ }; >+ >+ Becomes: >+ { >+ 'doi' => '123', >+ }; >+ >+=cut >+ >+sub trim_form_params { >+ my ( $self, $params ) = @_; >+ >+ return { map { $_ => $params->{$_} =~ s/^\s+|\s+$//gr } keys %$params }; >+} >+ > =head3 get_history_check_requests > > $self->get_history_check_requests(); >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index 0db9c09b1eb..f4b350b7f94 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -161,6 +161,7 @@ if ($backends_available) { > > # Ready to create ILL request > } else { >+ $params = $request->trim_form_params($params); > my $backend_result = $request->backend_create($params); > > # After creation actions >-- >2.39.5
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 39944
:
182668
|
182669
|
182672
|
182673