View | Details | Raw Unified | Return to bug 16365
Collapse All | Expand All

(-)a/C4/Biblio.pm (-7 / +14 lines)
Lines 932-938 sub GetISBDView { Link Here
932
    return unless defined $record;
932
    return unless defined $record;
933
    my $itemtype = &GetFrameworkCode($biblionumber);
933
    my $itemtype = &GetFrameworkCode($biblionumber);
934
    my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype );
934
    my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype );
935
    my $tagslib = &GetMarcStructure( 1, $itemtype );
935
    my $tagslib = &GetMarcStructure( 1, $itemtype, { unsafe => 1 } );
936
936
937
    my $ISBD = C4::Context->preference($sysprefname);
937
    my $ISBD = C4::Context->preference($sysprefname);
938
    my $bloc = $ISBD;
938
    my $bloc = $ISBD;
Lines 1109-1130 sub IsMarcStructureInternal { Link Here
1109
1109
1110
=head2 GetMarcStructure
1110
=head2 GetMarcStructure
1111
1111
1112
  $res = GetMarcStructure($forlibrarian,$frameworkcode);
1112
  $res = GetMarcStructure($forlibrarian, $frameworkcode, [ $params ]);
1113
1113
1114
Returns a reference to a big hash of hash, with the Marc structure for the given frameworkcode
1114
Returns a reference to a big hash of hash, with the Marc structure for the given frameworkcode
1115
$forlibrarian  :if set to 1, the MARC descriptions are the librarians ones, otherwise it's the public (OPAC) ones
1115
$forlibrarian  :if set to 1, the MARC descriptions are the librarians ones, otherwise it's the public (OPAC) ones
1116
$frameworkcode : the framework code to read
1116
$frameworkcode : the framework code to read
1117
1117
1118
TODO: add 'unsafe' parameter description and a warnings: what kinds of operations
1119
on the directly returned data structure are allowed / forbidden
1120
(autovivification of $tagslib->{$tag}->{$subfield} etc. are OK,
1121
but adding/removing/modifying any scalars in the "leafs" are strictly forbidden)
1122
1118
=cut
1123
=cut
1119
1124
1120
sub GetMarcStructure {
1125
sub GetMarcStructure {
1121
    my ( $forlibrarian, $frameworkcode ) = @_;
1126
    my ( $forlibrarian, $frameworkcode, $params ) = @_;
1122
    $frameworkcode = "" unless $frameworkcode;
1127
    $frameworkcode = "" unless $frameworkcode;
1123
1128
1124
    $forlibrarian = $forlibrarian ? 1 : 0;
1129
    $forlibrarian = $forlibrarian ? 1 : 0;
1130
    my $unsafe = ($params && $params->{unsafe})? 1: 0;
1125
    my $cache = Koha::Cache->get_instance();
1131
    my $cache = Koha::Cache->get_instance();
1126
    my $cache_key = "MarcStructure-$forlibrarian-$frameworkcode";
1132
    my $cache_key = "MarcStructure-$forlibrarian-$frameworkcode";
1127
    my $cached = $cache->get_from_cache($cache_key);
1133
    my $cached = $cache->get_from_cache($cache_key, { unsafe => $unsafe });
1128
    return $cached if $cached;
1134
    return $cached if $cached;
1129
1135
1130
    my $dbh = C4::Context->dbh;
1136
    my $dbh = C4::Context->dbh;
Lines 1937-1946 sub GetMarcAuthors { Link Here
1937
    }
1943
    }
1938
    my ( $mintag, $maxtag, $fields_filter );
1944
    my ( $mintag, $maxtag, $fields_filter );
1939
1945
1940
    # tagslib useful for UNIMARC author reponsabilities
1946
    # tagslib useful only for UNIMARC author responsibilities
1941
    my $tagslib =
1947
    my $tagslib;
1942
      &GetMarcStructure( 1, '' );    # FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct.
1943
    if ( $marcflavour eq "UNIMARC" ) {
1948
    if ( $marcflavour eq "UNIMARC" ) {
1949
        # FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct.
1950
        $tagslib = GetMarcStructure( 1, '', { unsafe => 1 });
1944
        $mintag = "700";
1951
        $mintag = "700";
1945
        $maxtag = "712";
1952
        $maxtag = "712";
1946
        $fields_filter = '7..';
1953
        $fields_filter = '7..';
(-)a/C4/Items.pm (-1 / +5 lines)
Lines 2431-2437 sub _get_unlinked_item_subfields { Link Here
2431
    my $original_item_marc = shift;
2431
    my $original_item_marc = shift;
2432
    my $frameworkcode = shift;
2432
    my $frameworkcode = shift;
2433
2433
2434
    my $marcstructure = GetMarcStructure(1, $frameworkcode);
2434
    my $marcstructure = GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
2435
2435
2436
    # assume that this record has only one field, and that that
2436
    # assume that this record has only one field, and that that
2437
    # field contains only the item information
2437
    # field contains only the item information
Lines 2815-2820 sub PrepareItemrecordDisplay { Link Here
2815
    my $dbh = C4::Context->dbh;
2815
    my $dbh = C4::Context->dbh;
2816
    $frameworkcode = &GetFrameworkCode($bibnum) if $bibnum;
2816
    $frameworkcode = &GetFrameworkCode($bibnum) if $bibnum;
2817
    my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2817
    my ( $itemtagfield, $itemtagsubfield ) = &GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2818
2819
    # it would be perhaps beneficial (?) to call GetMarcStructure with 'unsafe' parameter
2820
    # for performance reasons, but $tagslib may be passed to $plugin->build(), and there
2821
    # is no way to ensure that this structure is not getting corrupted somewhere in there
2818
    my $tagslib = &GetMarcStructure( 1, $frameworkcode );
2822
    my $tagslib = &GetMarcStructure( 1, $frameworkcode );
2819
2823
2820
    # return nothing if we don't have found an existing framework.
2824
    # return nothing if we don't have found an existing framework.
(-)a/C4/XSLT.pm (-1 / +1 lines)
Lines 68-74 Is only used in this module currently. Link Here
68
sub transformMARCXML4XSLT {
68
sub transformMARCXML4XSLT {
69
    my ($biblionumber, $record) = @_;
69
    my ($biblionumber, $record) = @_;
70
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
70
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
71
    my $tagslib = &GetMarcStructure(1,$frameworkcode);
71
    my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
72
    my @fields;
72
    my @fields;
73
    # FIXME: wish there was a better way to handle exceptions
73
    # FIXME: wish there was a better way to handle exceptions
74
    eval {
74
    eval {
(-)a/Koha/Filter/MARC/ViewPolicy.pm (-2 / +1 lines)
Lines 84-90 sub filter { Link Here
84
        my $frameworkcode = $self->{options}->{frameworkcode} // q{};
84
        my $frameworkcode = $self->{options}->{frameworkcode} // q{};
85
        my $hide          = _should_hide_on_interface();
85
        my $hide          = _should_hide_on_interface();
86
86
87
        my $marcsubfieldstructure = GetMarcStructure( 0, $frameworkcode );
87
        my $marcsubfieldstructure = GetMarcStructure( 0, $frameworkcode, { unsafe => 1 } );
88
88
89
        #if ($marcsubfieldstructure->{'000'}->{'@'}->{hidden}>0) {
89
        #if ($marcsubfieldstructure->{'000'}->{'@'}->{hidden}>0) {
90
        # LDR field is excluded from $current_record->fields().
90
        # LDR field is excluded from $current_record->fields().
91
- 

Return to bug 16365