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 2098-2107 or staff client strings. Link Here
2098
2096
2099
sub strings_map {
2097
sub strings_map {
2100
    my ( $self, $params ) = @_;
2098
    my ( $self, $params ) = @_;
2101
2099
    my $frameworkcode = C4::Biblio::GetFrameworkCode($self->biblionumber);
2102
    my $columns_info  = $self->_result->result_source->columns_info;
2100
    my $tagslib       = C4::Biblio::GetMarcStructure( 1, $frameworkcode, { unsafe => 1 } );
2103
    my $frameworkcode = $self->biblio->frameworkcode;
2104
    my $tagslib       = C4::Biblio::GetMarcStructure( 1, $frameworkcode );
2105
    my $mss           = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
2101
    my $mss           = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } );
2106
2102
2107
    my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber");
2103
    my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber");
Lines 2116-2122 sub strings_map { Link Here
2116
    # Handle not null and default values for integers and dates
2112
    # Handle not null and default values for integers and dates
2117
    my $strings = {};
2113
    my $strings = {};
2118
2114
2119
    foreach my $col ( keys %{$columns_info} ) {
2115
    foreach my $col ( @{$self->_columns} ) {
2120
2116
2121
        # By now, we are done with known columns, now check the framework for mappings
2117
        # By now, we are done with known columns, now check the framework for mappings
2122
        my $field = $self->_result->result_source->name . '.' . $col;
2118
        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 892-897 subtest 'record_schema test' => sub { Link Here
892
};
892
};
893
893
894
894
895
subtest 'GetFrameworkCode' => sub {
896
    plan tests => 4;
897
898
    my $biblio = $builder->build_sample_biblio({ frameworkcode => 'OBP' });
899
900
    is(GetFrameworkCode($biblio->biblionumber), 'OBP', 'GetFrameworkCode returns correct frameworkcode');
901
902
    my $cache = Koha::Cache::Memory::Lite->get_instance();
903
    my $cache_key = "FrameworkCode-" . $biblio->biblionumber;
904
    my $frameworkcode = $cache->get_from_cache($cache_key);
905
    is($frameworkcode, 'OBP', 'Cache has been set in GetFrameworkCode');
906
907
    # Set new value directly in cache to make sure it's actually being used
908
    $cache->set_in_cache($cache_key, 'OD');
909
    is(GetFrameworkCode($biblio->biblionumber), 'OD', 'GetFrameworkCode returns correct frameworkcode, using cache');
910
911
    # Test cache invalidation
912
    ModBiblio($biblio->metadata->record, $biblio->biblionumber, 'OGR');
913
    is(GetFrameworkCode($biblio->biblionumber), 'OGR', 'GetFrameworkCode returns correct frameworkcode after setting a new one though ModBiblio');
914
915
};
895
916
896
# Cleanup
917
# Cleanup
897
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
918
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
898
- 

Return to bug 32060