From 2c0b8352c35ea4c7220d4e98c2864d053682aa06 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 6 Feb 2026 09:34:44 +0100 Subject: [PATCH] Bug 41685: (QA follow-up) Resolve qa warnings Content-Type: text/plain; charset=utf-8 Resolve critic warn: "return" statement followed by "sort" at line 1238, column 5. Behavior is undefined if called in scalar context. (Severity: 5) Tidied with lastest perltidy version. Signed-off-by: Marcel de Rooy --- C4/AuthoritiesMarc.pm | 24 ++++++++++++++---------- t/db_dependent/AuthoritiesMarc.t | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index ebb33b978f..b0cc40ee14 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1077,7 +1077,7 @@ sub BuildSummary { } } my @fields = _marc21_sort_hierarchy_alpha( $record->field('4..') ); - foreach my $field (@fields) { #See From + foreach my $field (@fields) { #See From my $type = 'seefrom'; $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') ); if ( $type eq 'notapplicable' ) { @@ -1101,7 +1101,7 @@ sub BuildSummary { } } @fields = _marc21_sort_hierarchy_alpha( $record->field('5..') ); - foreach my $field (@fields) { #See Also + foreach my $field (@fields) { #See Also my $type = 'seealso'; $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') ); if ( $type eq 'notapplicable' ) { @@ -1235,14 +1235,18 @@ sub BuildSummary { sub _marc21_sort_hierarchy_alpha { my @fields = @_; - return sort { - # Sort broader (g) - no hierarchy (tric:gh) - narrower (h) - my $a_hier = $a->subfield('w') // q{}; $a_hier = 'gh' if $a_hier !~ /^[gh]$/; - my $b_hier = $b->subfield('w') // q{}; $b_hier = 'gh' if $b_hier !~ /^[gh]$/; - - # When hierarchy does not resolve, sort on $a - $a_hier cmp $b_hier || $a->subfield('a') cmp $b->subfield('a'); - } @fields; + return ( + sort { + # Sort broader (g) - no hierarchy (tric:gh) - narrower (h) + my $a_hier = $a->subfield('w') // q{}; + $a_hier = 'gh' if $a_hier !~ /^[gh]$/; + my $b_hier = $b->subfield('w') // q{}; + $b_hier = 'gh' if $b_hier !~ /^[gh]$/; + + # When hierarchy does not resolve, sort on $a + $a_hier cmp $b_hier || $a->subfield('a') cmp $b->subfield('a'); + } @fields + ); } =head2 GetAuthorizedHeading diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t index 681f428e0b..62099fe6ef 100755 --- a/t/db_dependent/AuthoritiesMarc.t +++ b/t/db_dependent/AuthoritiesMarc.t @@ -401,6 +401,7 @@ subtest 'DelAuthority() tests' => sub { subtest 'BuildSummary/_marc21_sort_hierarchy_alpha' => sub { plan tests => 1; + #$schema->storage->txn_begin; #t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); -- 2.39.5