From 174b425c36416a2725da81345ccaf162c4f7f873 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 1 May 2015 17:56:07 -0400 Subject: [PATCH] Bug 14115: Silence warnings in t/Label* Two functions were triggering noisy warnings while testing: _get_text_fields and _split_lccn. TEST PLAN ---------- 1) $ prove t/Label* -- several warnings 2) apply patch 3) $ prove t/Label* -- no warnings 4) koha qa test tools. Signed-off-by: Bernardo Gonzalez Kriegel Nicer, no koha-qa errors Signed-off-by: Aleisha Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Labels/Label.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 83093a4dbd..3b4318af03 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -115,7 +115,7 @@ sub _get_text_fields { my $csv = Text::CSV_XS->new({allow_whitespace => 1}); my $status = $csv->parse($format_string); my @sorted_fields = map {{ 'code' => $_, desc => $_ }} - map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653 + map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653 $csv->fields(); my $error = $csv->error_input(); warn sprintf('Text field sort failed with this error: %s', $error) if $error; @@ -129,10 +129,11 @@ sub _split_lccn { # lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996'; my @parts = Library::CallNumber::LC->new($lccn)->components(); unless (scalar @parts && defined $parts[0]) { - warn sprintf('regexp failed to match string: %s', $_); + $debug and warn sprintf('regexp failed to match string: %s', $_); @parts = $_; # if no match, just use the whole string. } - push @parts, split /\s+/, pop @parts; # split the last piece into an arbitrary number of pieces at spaces + my $LastPiece = pop @parts; + push @parts, split /\s+/, $LastPiece if $LastPiece; # split the last piece into an arbitrary number of pieces at spaces $debug and warn "split_lccn array: ", join(" | ", @parts), "\n"; return @parts; } -- 2.39.5