Bugzilla – Attachment 175903 Details for
Bug 38751
Creating ILL request through OPAC openURL explodes if same attribute defined twice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38751: Update ILL::Request->extended_attributes
Bug-38751-Update-ILLRequest-extendedattributes.patch (text/plain), 2.89 KB, created by
David Nind
on 2024-12-22 22:05:46 UTC
(
hide
)
Description:
Bug 38751: Update ILL::Request->extended_attributes
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-12-22 22:05:46 UTC
Size:
2.89 KB
patch
obsolete
>From f727129643665548b44d2d568412f654e62a8ca0 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 19 Dec 2024 11:55:48 +0000 >Subject: [PATCH] Bug 38751: Update ILL::Request->extended_attributes > >This updates the extended_attributes method to also act as setter. >Additionally, it'll skip adding any attribute that result in error, preventing an ugly error 500. > >Test plan: >1) Enable ILLModule sys pref >2) Attempt to create the following openurl request through the OPAC: >http://localhost:8080/cgi-bin/koha/opac-illrequests.pl?DOI=10.1001%2Fjama.2024.11146&atitle=Interventions%20for%20High%20Body%20Mass%20Index%20in%20Children%20and%20Adolescents%3A%20US%20Preventive%20Services%20Task%20Force%20Recommendation%20Statement.&aulast=Nicholson%2C%20Wanda%20K.&backend=FreeForm&cardnumber=53807898&date=20240716&genre=article&id=DOI%3A10.1001%2Fjama.2024.11146&issn=00987484&issue=3&method=create&opac=1&openurl=1 >3) Notice it fails with a Duplicate ID error and the OPAC blows up. This is because Koha is trying to add the 'DOI' illrequestattribute twice and that is resulting in a duplicate ID >4) Apply patches, repeat test plan, notice the error no longer happens, the request is created correctly and all successful attribute have been added. > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/ILL/Request.pm | 34 ++++++++++++++++++++++++++++++++-- > 1 file changed, 32 insertions(+), 2 deletions(-) > >diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm >index 4bf239ce6a..dbb809b48d 100644 >--- a/Koha/ILL/Request.pm >+++ b/Koha/ILL/Request.pm >@@ -277,12 +277,42 @@ sub library { > > my $extended_attributes = $request->extended_attributes; > >-Returns the linked I<Koha::ILL::Request::Attributes> resultset object. >+ my $extended_attributes = $request->extended_attributes([ >+ { >+ type => 'type', >+ value => 'type_value', >+ }, >+ { >+ type => 'type2', >+ value => 'type2_value', >+ }, >+ ]); >+ >+Getter or setter for extended attributes >+ >+Getter: Returns the linked I <Koha::ILL::Request::Attributes> resultset object. >+ >+Setter: Adds the supplied extended attributes to the request > > =cut > > sub extended_attributes { >- my ( $self ) = @_; >+ my ( $self, $attributes ) = @_; >+ >+ if ($attributes) { >+ my $schema = $self->_result->result_source->schema; >+ $schema->txn_do( >+ sub { >+ for my $attribute (@$attributes) { >+ $attribute->{backend} = $self->backend; >+ eval { $self->_result->add_to_illrequestattributes($attribute); }; >+ if ($@) { >+ warn "Error adding attribute $attribute->{type}: $@"; >+ } >+ } >+ } >+ ); >+ } > > my $rs = $self->_result->extended_attributes; > # We call search to use the filters in Koha::ILL::Request::Attributes->search >-- >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 38751
:
175700
|
175701
|
175702
|
175703
|
175704
|
175705
|
175903
|
175904
|
175905
|
176124
|
176250
|
176251
|
176252
|
176253