From db7f3b5c388a12a33098697f1fa7e94ad10b6848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Mon, 22 Sep 2025 15:16:12 -0300 Subject: [PATCH] Bug 40850: (follow-up) Use add_or_update_attributes in copyright clearance methods This patch simplifies the set_copyright_clearance_confirmed() method to use the new add_or_update_attributes() method instead of custom update/create logic. Benefits: - Reduces code complexity from 20+ lines to 6 lines - Eliminates duplicate update/create logic - Uses the new standardized method for attribute management - Maintains all existing functionality and test coverage Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/ILL/Request.t => SUCCESS: Tests pass! Copyright clearance methods work with new implementation 3. Test copyright clearance workflow still works in ILL module 4. Sign off :-D --- Koha/ILL/Request.pm | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index f6892fc7e2..0f4e0af8a1 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -1319,25 +1319,9 @@ sub set_copyright_clearance_confirmed { # Normalize to boolean: 0 or 1 my $value = $confirmed ? 1 : 0; - # Check if attribute already exists - my $existing_attr = $self->extended_attributes->find( { type => 'copyrightclearance_confirmed' } ); + $self->add_or_update_attributes( { copyrightclearance_confirmed => $value } ); - if ($existing_attr) { - - # Update existing attribute - $existing_attr->value($value)->store; - } else { - - # Create new attribute - $self->extended_attributes( - [ - { - type => 'copyrightclearance_confirmed', - value => $value, - } - ] - ); - } + return $self; } =head3 add_or_update_attributes -- 2.51.0