From 3fc80c35aa4dcf863fb3b437e1530d5791a3baeb Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Mon, 1 Apr 2019 14:09:10 +0100 Subject: [PATCH] Bug 22614: Migrate original request This patch changes an active request's backend and initiates the migration on that request, rather than creating another and migrating that. The majority of the work to accomplish this bug is being carried out in the backends, since Koha delegates migrations to them. Signed-off-by: Barry Cannon Signed-off-by: Assumpta Byrne Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 3 ++- Koha/Illrequest/Logger.pm | 4 ++++ ill/ill-requests.pl | 6 ++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 2eaa5accda..7decbc1f2d 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -718,7 +718,8 @@ Migrate a request from one backend to another. sub backend_migrate { my ( $self, $params ) = @_; - + # Set the request's backend to be the destination backend + $self->load_backend($params->{backend}); my $response = $self->_backend_capability('migrate',{ request => $self, other => $params, diff --git a/Koha/Illrequest/Logger.pm b/Koha/Illrequest/Logger.pm index 2e7b1f09d7..31f1704446 100644 --- a/Koha/Illrequest/Logger.pm +++ b/Koha/Illrequest/Logger.pm @@ -215,6 +215,10 @@ sub get_log_template { } else { # It's probably a backend log, so we need to get the path to the # template from the backend + # + # We need to load the backend that this log was made from, so we + # can get the template + $params->{request}->load_backend($origin); my $backend =$params->{request}->{_my_backend}; return $backend->get_log_template_path($action); } diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index fef5e550c7..6898e5b886 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -152,14 +152,12 @@ if ( $backends_available ) { my $request = Koha::Illrequests->find($params->{illrequest_id}); my $backend_result; if ( $params->{backend} ) { - my $new_request = Koha::Illrequest->new->load_backend( $params->{backend} ); - $backend_result = $new_request->backend_migrate($params); + $backend_result = $request->backend_migrate($params); if ($backend_result) { $template->param( whole => $backend_result, - request => $new_request + request => $request ); - $request = $new_request; } else { # Backend failure, redirect back to illview print $cgi->redirect( '/cgi-bin/koha/ill/ill-requests.pl' -- 2.39.5