Bugzilla – Attachment 186736 Details for
Bug 40850
Add `Koha::ILL::Request->add_or_update_attributes`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40850: (follow-up) Use add_or_update_attributes in Standard backend
Bug-40850-follow-up-Use-addorupdateattributes-in-S.patch (text/plain), 3.91 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-09-22 18:25:39 UTC
(
hide
)
Description:
Bug 40850: (follow-up) Use add_or_update_attributes in Standard backend
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-09-22 18:25:39 UTC
Size:
3.91 KB
patch
obsolete
>From 830ab19a3f1c2376a83d19dcde17845058ec5b43 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Mon, 22 Sep 2025 15:18:44 -0300 >Subject: [PATCH] Bug 40850: (follow-up) Use add_or_update_attributes in > Standard backend > >This patch updates the Standard ILL backend to use the new >add_or_update_attributes() method instead of the problematic >extended_attributes() method that only supports adding new >attributes. > >Changes: >- Request creation: Use add_or_update_attributes() for setting metadata >- Request migration: Use add_or_update_attributes() for copying attributes > >Benefits: >- Eliminates duplicate key errors when updating existing requests >- Cleaner code - removes array-to-hash conversion boilerplate >- More efficient - only updates attributes when values change >- Consistent with new Koha::ILL::Request API patterns > >Locations updated: >- add_request(): Request creation with metadata (line ~1017) >- migrate(): Request migration copying attributes (line ~731) > >Test plan: >1. Apply patch >2. Test ILL request creation in Standard backend: > - Create new ILL request with metadata > => SUCCESS: Request created with attributes >3. Test ILL request migration: > - Migrate existing request to new request > => SUCCESS: Attributes copied correctly >4. Test updating existing request metadata: > - Edit request and update metadata fields > => SUCCESS: No duplicate key errors >5. Sign off :-D >--- > Koha/ILL/Backend/Standard.pm | 39 +++++++----------------------------- > 1 file changed, 7 insertions(+), 32 deletions(-) > >diff --git a/Koha/ILL/Backend/Standard.pm b/Koha/ILL/Backend/Standard.pm >index acc7bda9c5..57529f049f 100644 >--- a/Koha/ILL/Backend/Standard.pm >+++ b/Koha/ILL/Backend/Standard.pm >@@ -716,19 +716,11 @@ sub migrate { > my $original_attributes = > $original_request->extended_attributes->search( { type => { '-in' => \@default_attributes } } ); > >- my @request_details_array = map { >- { >- 'type' => $_->type, >- 'value' => $_->value, >- } >- } $original_attributes->as_list; >- >- push @request_details_array, { >- 'type' => 'migrated_from', >- 'value' => $original_request->illrequest_id, >- }; >+ # Build attributes hash directly >+ my %attributes = map { $_->type => $_->value } $original_attributes->as_list; >+ $attributes{migrated_from} = $original_request->illrequest_id; > >- $new_request->extended_attributes( \@request_details_array ); >+ $new_request->add_or_update_attributes( \%attributes ); > > return { > error => 0, >@@ -809,19 +801,8 @@ sub _set_requested_partners { > # the time we get to this stage, any previous request > # from partners would have had to be cancelled > my ($args) = @_; >- my $where = { >- illrequest_id => $args->{request}->id, >- type => 'requested_partners' >- }; >- Koha::ILL::Request::Attributes->search($where)->delete(); >- Koha::ILL::Request::Attribute->new( >- { >- illrequest_id => $args->{request}->id, >- column_exists( 'illrequestattributes', 'backend' ) ? ( backend => "Standard" ) : (), >- type => 'requested_partners', >- value => $args->{to} >- } >- )->store; >+ >+ $args->{request}->add_or_update_attributes( { requested_partners => $args->{to} } ); > } > > =head3 _validate_borrower >@@ -1008,13 +989,7 @@ sub add_request { > if column_exists( 'illrequests', 'batch_id' ); > $request->store; > >- my @request_details_array = map { >- { >- 'type' => $_, >- 'value' => $request_details->{$_}, >- } >- } keys %{$request_details}; >- $request->extended_attributes( \@request_details_array ); >+ $request->add_or_update_attributes($request_details); > $request->add_unauthenticated_data( $params->{other} ) if $unauthenticated_request; > > $request->after_created; >-- >2.51.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 40850
:
186734
|
186735
|
186736
|
186755
|
186756
|
186757