From d6011d6ae92bf1505719d695aa6715bfc54b4496 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 30 Oct 2023 13:00:01 +0000 Subject: [PATCH] Bug 19097: Adjust some GetMarcFromKohaField calls We need to: [1] Remove obsolete framework parameters if any (yes there are). [2] Check scalar context calls if any (most probably not). Ad 1: How to find them? Git grep and look at each hit. You will need the -C parameter to add a few context lines around the call even. Found one in C4/Biblio.pm and six in Suggestions.t with ''. Found one in C4/Items on a second line. Similar one in Koha/EDI. Note: sub receipt_items in EDI has no unit tests yet. Also did a few git searches like: git grep GetMarcFromKohaField | grep -v -P "GetMarcFromKohaField.*;"| grep -P "GetMarcFromKohaField\s*\(" Note: Seeing still three lines; they are all fine. Last line comes from testing to trigger the warn. Ad 2: Have been looking at each git grep line and did not spot any scalar context call. Before this report, we had an example in POD and the Biblio test only. Try to find them by performing smarter git searches? Did look again at results for: git grep GetMarcFromKohaField | grep -v -P "\)\s*=\s*&?(C4::Biblio::)?GetMarcFromKohaField" | grep -v -P "use " The tests from this grep are included in the last test plan line. Test plan: Read the patch. Run t/db_dependent/Biblio/TransformHtmlToMarc.t Run t/db_dependent/Items.t Run t/db_dependent/Suggestions.t Run prove t/Biblio2.t t/db_dependent/Biblio.t t/db_dependent/Filter_MARC_ViewPolicy.t t/db_dependent/Koha/Authorities.t t/db_dependent/Koha/Biblio/Metadata.t t/db_dependent/Koha/Filter/EmbedItemsAvailability.t t/db_dependent/Koha/SearchEngine/Search.t t/db_dependent/XISBN.t Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- C4/Biblio.pm | 3 +-- C4/Items.pm | 4 +--- Koha/EDI.pm | 3 +-- t/db_dependent/Suggestions.t | 12 ++++++------ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 833701c476..af25bd1142 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2245,8 +2245,7 @@ sub TransformHtmlToMarc { my $record = MARC::Record->new(); my @fields; my ($biblionumbertagfield, $biblionumbertagsubfield) = (-1, -1); - ($biblionumbertagfield, $biblionumbertagsubfield) = - &GetMarcFromKohaField( "biblio.biblionumber", '' ) if $isbiblio; + ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField("biblio.biblionumber") if $isbiblio; #FIXME This code assumes that the CGI params will be in the same order as the fields in the template; this is no absolute guarantee! for (my $i = 0; $params[$i]; $i++ ) { # browse all CGI params my $param = $params[$i]; diff --git a/C4/Items.pm b/C4/Items.pm index d2fa257ef5..519e6d1471 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -778,9 +778,7 @@ sub Item2Marc { }; my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); my $itemmarc = C4::Biblio::TransformKohaToMarc( $mungeditem, { framework => $framework } ); - my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( - "items.itemnumber", $framework, - ); + my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField('items.itemnumber'); my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); if (defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1) { diff --git a/Koha/EDI.pm b/Koha/EDI.pm index ad7ea7a075..137a2210c2 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -476,8 +476,7 @@ sub receipt_items { my $order = Koha::Acquisition::Orders->find($ordernumber); $biblionumber = $order->biblionumber; my $frameworkcode = GetFrameworkCode($biblionumber); - ($itemfield) = GetMarcFromKohaField( 'items.itemnumber', - $frameworkcode ); + ($itemfield) = GetMarcFromKohaField('items.itemnumber'); } } diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 88aae138c1..97a0d80ab9 100755 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -379,11 +379,11 @@ my $record = MarcRecordFromNewSuggestion($suggestion2); is("MARC::Record", ref($record), "MarcRecordFromNewSuggestion should return a MARC::Record object"); -my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title', ''); +my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title'); is($record->field( $title_tag )->subfield( $title_subfield ), "Cuisine d'automne", "Record from suggestion title should be 'Cuisine d'automne'"); -my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author', ''); +my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author'); is($record->field( $author_tag )->subfield( $author_subfield ), "Catherine", "Record from suggestion author should be 'Catherine'"); @@ -649,16 +649,16 @@ subtest 'Suggestion with ISBN' => sub { my $record = MarcRecordFromNewSuggestion( $suggestion_with_isbn ); is("MARC::Record", ref($record), "MarcRecordFromNewSuggestion should return a MARC::Record object"); - my ($isbn_tag, $isbn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.isbn', ''); + my ($isbn_tag, $isbn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.isbn'); is($record->field( $isbn_tag )->subfield( $isbn_subfield ), "1940997232", "ISBN Record from suggestion ISBN should be '1940997232'"); - my ($issn_tag, $issn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.issn', ''); + my ($issn_tag, $issn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.issn'); is($record->field( $issn_tag )->subfield( $issn_subfield ), "1940997232", "ISSN Record from suggestion ISBN should also be '1940997232'"); - my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title', ''); + my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title'); is($record->field( $title_tag), undef, "Record from suggestion title should be empty"); - my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author', ''); + my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author'); is($record->field( $author_tag), undef, "Record from suggestion author should be empty"); }; -- 2.39.5