From 52eda9ba69de2befa3b183c87f49800c54471c00 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 14 May 2025 14:52:07 +0000 Subject: [PATCH] Bug 39904: EDIFACT error messages are malformed Perl can interpolate hashrefs but not method calls. This results in messages like "Cannot connect to Koha::Schema::Result::VendorEdiAccount=HASH(0xaaab059252f0)->host: Name or service not known: My Test at ./misc/cronjobs/edi_cron.pl line 58." when running the edi_cron.pl cronjob. Test Plan: 1) Enable EDIFACT 2) Create a fake EDI account with a bad FTP server in it 3) Run edi_cron.pl 4) Note the errors like: Cannot connect to Koha::Schema::Result::VendorEdiAccount=HASH(0xaaab059252f0)->host: Name or service not known: My Test at ./misc/cronjobs/edi_cron.pl line 58. 5) Apply this patch 6) Run edi_cron.pl 7) Note the errors are now like: Cannot connect to test.example.com: Name or service not known: My Test at ./misc/cronjobs/edi_cron.pl line 58. Signed-off-by: David Nind Signed-off-by: Emily Lamancusa Signed-off-by: Katrin Fischer (cherry picked from commit 26e7c07302842eaca9942ac7f0a74db5e3abd07f) Signed-off-by: Fridolin Somers --- Koha/Edifact/Transport.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm index ebc5d801c8..777312d298 100644 --- a/Koha/Edifact/Transport.pm +++ b/Koha/Edifact/Transport.pm @@ -228,13 +228,13 @@ sub ftp_download { ) or return $self->_abort_download( undef, - "Cannot connect to $self->{account}->host: $EVAL_ERROR" + "Cannot connect to " . $self->{account}->host . ": $EVAL_ERROR" ); $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) ) or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); $ftp->cwd( $self->{account}->download_directory ) or return $self->_abort_download( $ftp, - "Cannot change remote dir : $ftp->message()" ); + "Cannot change remote dir : " . $ftp->message() ); my $file_list = $ftp->ls() or return $self->_abort_download( $ftp, 'cannot get file list from server' ); @@ -273,13 +273,13 @@ sub ftp_upload { ) or return $self->_abort_download( undef, - "Cannot connect to $self->{account}->host: $EVAL_ERROR" + "Cannot connect to " . $self->{account}->host . ": $EVAL_ERROR" ); $ftp->login( $self->{account}->username, Koha::Encryption->new->decrypt_hex($self->{account}->password) ) or return $self->_abort_download( $ftp, "Cannot login: $ftp->message()" ); $ftp->cwd( $self->{account}->upload_directory ) or return $self->_abort_download( $ftp, - "Cannot change remote dir : $ftp->message()" ); + "Cannot change remote dir : " . $ftp->message() ); foreach my $m (@messages) { my $content = $m->raw_msg; if ($content) { @@ -311,7 +311,7 @@ sub sftp_upload { port => $port, timeout => 10, ); - $sftp->die_on_error("Cannot ssh to $self->{account}->host"); + $sftp->die_on_error( "Cannot ssh to " . $self->{account}->host ); $sftp->setcwd( $self->{account}->upload_directory ) or return $self->_abort_download( $sftp, "Cannot change remote dir : " . $sftp->error );