Bug 38751: Update Standard ILL backend migrate

Make use of newly updated ILL::Request->extended_attributes method instead of creating the query manually

The test plan in bug 38819 fails without this patch (page explodes with duplicate ID error).
It's the same cause as the one being fixed here in bug 38751 so I'm submitting this here.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2025-01-03 12:15:47 -01:00 committed by Katrin Fischer
parent 6526e00374
commit 92fd65840a
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -698,19 +698,19 @@ sub migrate {
my $original_attributes =
$original_request->extended_attributes->search( { type => { '-in' => \@default_attributes } } );
my $request_details =
{ map { $_->type => $_->value } ( $original_attributes->as_list ) };
$request_details->{migrated_from} = $original_request->illrequest_id;
while ( my ( $type, $value ) = each %{$request_details} ) {
Koha::ILL::Request::Attribute->new(
{
illrequest_id => $new_request->illrequest_id,
column_exists( 'illrequestattributes', 'backend' ) ? ( backend => "Standard" ) : (),
type => $type,
value => $value,
}
)->store;
}
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,
};
$new_request->extended_attributes( \@request_details_array );
return {
error => 0,
@ -993,8 +993,8 @@ sub add_request {
my @request_details_array = map {
{
'type' => $_,
'value' => $request_details->{$_},
'type' => $_,
'value' => $request_details->{$_},
}
} keys %{$request_details};
$request->extended_attributes( \@request_details_array );