diff --git a/C4/Koha.pm b/C4/Koha.pm index 3b990299cd..1b2164dbaf 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1396,8 +1396,11 @@ sub GetVariationsOfISSN { my @issns; - push( @issns, NormalizeISSN({ issn => $issn }) ); - push( @issns, NormalizeISSN({ issn => $issn, strip_hyphen => 1 }) ); + if( NormalizeISSN({issn => $issn}) ){ + push( @issns, NormalizeISSN({ issn => $issn }) ); + push( @issns, NormalizeISSN({ issn => $issn, strip_hyphen => 1 }) ); + } + else { push( @issns, $issn) } # Strip out any "empty" strings from the array @issns = grep { defined($_) && $_ =~ /\S/ } @issns; diff --git a/t/Koha.t b/t/Koha.t index 500dcb5c9e..e617146f93 100755 --- a/t/Koha.t +++ b/t/Koha.t @@ -25,7 +25,7 @@ use Module::Load::Conditional qw/check_install/; BEGIN { if ( check_install( module => 'Test::DBIx::Class' ) ) { - plan tests => 37; + plan tests => 38; } else { plan skip_all => "Need Test::DBIx::Class" } @@ -152,6 +152,7 @@ eval { ok($@ eq '', 'NormalizeISSN does not throw exception when parsing invalid ISSN'); @issns = GetVariationsOfISSNs('abc'); -is(scalar(@issns), 0, 'zero variations returned of invalid ISSN'); +is($issns[0], 'abc', 'Original ISSN passed through even if invalid'); +is(scalar(@issns), 1, 'zero additional variations returned of invalid ISSN'); 1;