[Koha-bugs] [Bug 32464] Koha::Item->as_marc_field obsolete option mss

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue May 2 13:45:26 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32464

--- Comment #14 from Jonathan Druart <jonathan.druart+koha at gmail.com> ---
(In reply to Nick Clemens from comment #13)
> See comment 5, please test

What/how did you test?

What I've done:

Add 1000 items to biblio 1

use t::lib::TestBuilder;
my $b = t::lib::TestBuilder->new;
for (1..1000){
    $b->build_sample_item({biblionumber => 1});
}

time that:
use Modern::Perl;
use Koha::Biblios;
use Koha::Patrons;
my $biblio = Koha::Biblios->find(1);
my $patron = Koha::Patrons->find(51);
my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
my $record = $biblio->metadata->record;
my $record_processor = Koha::RecordProcessor->new({
    filters => [ 'EmbedItems', 'ViewPolicy' ],
    options => { 
        interface     => 'opac',
        frameworkcode => $biblio->frameworkcode,
        items         => [ $items->as_list ],
    }    
});

With this change:
diff --git a/Koha/Item.pm b/Koha/Item.pm
index 7251a8a094f..c1e948f0795 100644
--- a/Koha/Item.pm
+++ b/Koha/Item.pm
@@ -939,16 +939,14 @@ with the current mappings configuration.
 =cut

 sub as_marc_field {
-    my ( $self ) = @_;
-
-    my ( $itemtag, $itemtagsubfield) = C4::Biblio::GetMarcFromKohaField(
"items.itemnumber" );
+    my ( $self, $params ) = @_;

-    my $tagslib = C4::Biblio::GetMarcStructure( 1,
$self->biblio->frameworkcode, { unsafe => 1 });
+    my $mss = $params->{mss} // C4::Biblio::GetMarcSubfieldStructure( '', {
unsafe => 1 } );
+    #my $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } );
+    my $itemtag = $mss->{'items.itemnumber'}[0]->{tagfield};
+    my $item_field = $mss->{$itemtag};

     my @subfields;
-
-    my $item_field = $tagslib->{$itemtag};
-
     my $more_subfields = $self->additional_attributes->to_hashref;
     foreach my $subfield (
         sort {

Switching the 'my $mss' line.

No difference noted (script takes ~4.5sec).

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list