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 <david@davidnind.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Kyle M Hall 2025-05-14 14:52:07 +00:00 committed by Katrin Fischer
parent 0bfad63507
commit 26e7c07302
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 5 additions and 5 deletions

View File

@ -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,