Bugzilla – Attachment 184549 Details for
Bug 40386
t/Edifact.t generates warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40386: Remove warnings from EDI when running tests
Bug-40386-Remove-warnings-from-EDI-when-running-te.patch (text/plain), 2.69 KB, created by
Jonathan Druart
on 2025-07-23 12:35:46 UTC
(
hide
)
Description:
Bug 40386: Remove warnings from EDI when running tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-23 12:35:46 UTC
Size:
2.69 KB
patch
obsolete
>From a7b5b78f80a3bc9826c2c3194b7dd4e296c9df0c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 10 Jul 2025 16:52:41 +0100 >Subject: [PATCH] Bug 40386: Remove warnings from EDI when running tests > >This patch fixes several warnings that occur when running Edifact tests: > >1. Changed `my $self = ()` to `my $self = {}` in Koha::Edifact constructor > to properly initialize as hashref instead of empty list >2. Added null/empty checks in Koha::Edifact::Segment::_parse_seg() to prevent > warnings when processing undefined or empty segments >3. Added null/empty checks in Koha::Edifact::Segment::_get_elements() to > handle undefined segments gracefully >4. Added Test::NoWarnings to t/Edifact.t to catch any remaining warnings > >These changes eliminate "Use of uninitialized value" warnings and ensure >clean test runs without affecting EDI functionality. > >Test plan: >1. Run prove t/Edifact.t and verify no warnings are displayed >2. Test EDI message processing to ensure no regression > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Edifact.pm | 2 +- > Koha/Edifact/Segment.pm | 7 +++++++ > t/Edifact.t | 3 ++- > 3 files changed, 10 insertions(+), 2 deletions(-) > >diff --git a/Koha/Edifact.pm b/Koha/Edifact.pm >index 7479a9b42b5..ada773b9ca4 100644 >--- a/Koha/Edifact.pm >+++ b/Koha/Edifact.pm >@@ -36,7 +36,7 @@ my $separator = { > sub new { > my ( $class, $param_hashref ) = @_; > my $transmission; >- my $self = (); >+ my $self = {}; > > if ( $param_hashref->{filename} ) { > if ( $param_hashref->{transmission} ) { >diff --git a/Koha/Edifact/Segment.pm b/Koha/Edifact/Segment.pm >index 563b3e72224..a9600168e0a 100644 >--- a/Koha/Edifact/Segment.pm >+++ b/Koha/Edifact/Segment.pm >@@ -86,6 +86,10 @@ sub as_string { > # parse a string into fields > sub _parse_seg { > my $s = shift; >+ >+ # Handle undefined or empty segments >+ return { tag => '', elem_arr => [] } unless defined $s && length $s >= 3; >+ > my $e = { > tag => substr( $s, 0, 3 ), > elem_arr => _get_elements( substr( $s, 3 ) ), >@@ -100,6 +104,9 @@ sub _parse_seg { > sub _get_elements { > my $seg = shift; > >+ # Handle undefined or empty segments >+ return [] unless defined $seg; >+ > $seg =~ s/^[+]//; # dont start with a dummy element` > my @elem_array = map { _components($_) } split /(?<![?])[+]/, $seg; > >diff --git a/t/Edifact.t b/t/Edifact.t >index 55d35d85dfa..9dec48c28f7 100755 >--- a/t/Edifact.t >+++ b/t/Edifact.t >@@ -3,7 +3,8 @@ use strict; > use warnings; > use FindBin qw( $Bin ); > >-use Test::More tests => 41; >+use Test::NoWarnings; >+use Test::More tests => 42; > use Koha::EDI; > > BEGIN { use_ok('Koha::Edifact') } >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40386
:
184374
| 184549