From 840f81c32c73cb9f9d8432c56829165eac7a63a2 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. --- 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 a26f2842ffb..72979924bac 100644 --- a/Koha/Edifact/Transport.pm +++ b/Koha/Edifact/Transport.pm @@ -230,14 +230,14 @@ 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' ); @@ -278,14 +278,14 @@ 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; @@ -318,7 +318,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, -- 2.39.5