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

(-)a/C4/Biblio.pm (-4 / +13 lines)
Lines 1830-1839 sub UpsertMarcControlField { Link Here
1830
1830
1831
sub GetFrameworkCode {
1831
sub GetFrameworkCode {
1832
    my ($biblionumber) = @_;
1832
    my ($biblionumber) = @_;
1833
    my $dbh            = C4::Context->dbh;
1833
    my $cache = Koha::Cache::Memory::Lite->get_instance();
1834
    my $sth            = $dbh->prepare("SELECT frameworkcode FROM biblio WHERE biblionumber=?");
1834
    my $cache_key = "FrameworkCode-$biblionumber";
1835
    $sth->execute($biblionumber);
1835
    my $frameworkcode = $cache->get_from_cache($cache_key);
1836
    my ($frameworkcode) = $sth->fetchrow;
1836
    unless (defined $frameworkcode) {
1837
        my $dbh = C4::Context->dbh;
1838
        my $sth = $dbh->prepare("SELECT frameworkcode FROM biblio WHERE biblionumber=?");
1839
        $sth->execute($biblionumber);
1840
        ($frameworkcode) = $sth->fetchrow;
1841
        $cache->set_in_cache($cache_key, $frameworkcode);
1842
    }
1837
    return $frameworkcode;
1843
    return $frameworkcode;
1838
}
1844
}
1839
1845
Lines 2555-2560 sub _koha_modify_biblio { Link Here
2555
        $biblio->{'abstract'}, $biblio->{'biblionumber'}
2561
        $biblio->{'abstract'}, $biblio->{'biblionumber'}
2556
    ) if $biblio->{'biblionumber'};
2562
    ) if $biblio->{'biblionumber'};
2557
2563
2564
    my $cache = Koha::Cache::Memory::Lite->get_instance();
2565
    $cache->clear_from_cache("FrameworkCode-" . $biblio->{biblionumber});
2566
2558
    if ( $dbh->errstr || !$biblio->{'biblionumber'} ) {
2567
    if ( $dbh->errstr || !$biblio->{'biblionumber'} ) {
2559
        $error .= "ERROR in _koha_modify_biblio $query" . $dbh->errstr;
2568
        $error .= "ERROR in _koha_modify_biblio $query" . $dbh->errstr;
2560
        warn $error;
2569
        warn $error;
(-)a/Koha/Item.pm (-11 / +7 lines)
Lines 1051-1066 This is meant to be used for display purpose only. Link Here
1051
1051
1052
sub columns_to_str {
1052
sub columns_to_str {
1053
    my ( $self ) = @_;
1053
    my ( $self ) = @_;
1054
    my $frameworkcode = C4::Biblio::GetFrameworkCode($self->biblionumber);
1055
    my $tagslib       = C4::Biblio::GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } );
1056
    my $mss           = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
1054
1057
1055
    my $frameworkcode = $self->biblio->frameworkcode;
1056
    my $tagslib = C4::Biblio::GetMarcStructure(1, $frameworkcode);
1057
    my ( $itemtagfield, $itemtagsubfield) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" );
1058
    my ( $itemtagfield, $itemtagsubfield) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" );
1058
1059
1059
    my $columns_info = $self->_result->result_source->columns_info;
1060
1061
    my $mss = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
1062
    my $values = {};
1060
    my $values = {};
1063
    for my $column ( keys %$columns_info ) {
1061
    for my $column ( @{$self->_columns}) {
1064
1062
1065
        next if $column eq 'more_subfields_xml';
1063
        next if $column eq 'more_subfields_xml';
1066
1064
Lines 2099-2108 or staff client strings. Link Here
2099
2097
2100
sub strings_map {
2098
sub strings_map {
2101
    my ( $self, $params ) = @_;
2099
    my ( $self, $params ) = @_;
2102
2100
    my $frameworkcode = C4::Biblio::GetFrameworkCode($self->biblionumber);
2103
    my $columns_info  = $self->_result->result_source->columns_info;
2101
    my $tagslib       = C4::Biblio::GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } );
2104
    my $frameworkcode = $self->biblio->frameworkcode;
2105
    my $tagslib       = C4::Biblio::GetMarcStructure( 1, $frameworkcode );
2106
    my $mss           = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
2102
    my $mss           = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
2107
2103
2108
    my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber");
2104
    my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber");
Lines 2117-2123 sub strings_map { Link Here
2117
    # Handle not null and default values for integers and dates
2113
    # Handle not null and default values for integers and dates
2118
    my $strings = {};
2114
    my $strings = {};
2119
2115
2120
    foreach my $col ( keys %{$columns_info} ) {
2116
    foreach my $col ( @{$self->_columns} ) {
2121
2117
2122
        # By now, we are done with known columns, now check the framework for mappings
2118
        # By now, we are done with known columns, now check the framework for mappings
2123
        my $field = $self->_result->result_source->name . '.' . $col;
2119
        my $field = $self->_result->result_source->name . '.' . $col;
(-)a/t/db_dependent/Biblio.t (-2 / +22 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 17;
20
use Test::More tests => 18;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
use List::MoreUtils qw( uniq );
23
use List::MoreUtils qw( uniq );
Lines 909-914 subtest 'record_schema test' => sub { Link Here
909
};
909
};
910
910
911
911
912
subtest 'GetFrameworkCode' => sub {
913
    plan tests => 4;
914
915
    my $biblio = $builder->build_sample_biblio({ frameworkcode => 'OBP' });
916
917
    is(GetFrameworkCode($biblio->biblionumber), 'OBP', 'GetFrameworkCode returns correct frameworkcode');
918
919
    my $cache = Koha::Cache::Memory::Lite->get_instance();
920
    my $cache_key = "FrameworkCode-" . $biblio->biblionumber;
921
    my $frameworkcode = $cache->get_from_cache($cache_key);
922
    is($frameworkcode, 'OBP', 'Cache has been set in GetFrameworkCode');
923
924
    # Set new value directly in cache to make sure it's actually being used
925
    $cache->set_in_cache($cache_key, 'OD');
926
    is(GetFrameworkCode($biblio->biblionumber), 'OD', 'GetFrameworkCode returns correct frameworkcode, using cache');
927
928
    # Test cache invalidation
929
    ModBiblio($biblio->metadata->record, $biblio->biblionumber, 'OGR');
930
    is(GetFrameworkCode($biblio->biblionumber), 'OGR', 'GetFrameworkCode returns correct frameworkcode after setting a new one though ModBiblio');
931
932
};
912
933
913
# Cleanup
934
# Cleanup
914
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
935
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
915
- 

Return to bug 32060