CountItemsIssued
ModBiblio
ModZebra
- EmbedItemsInMarcBiblio
UpdateTotalIssues
RemoveAllNsb
DelBiblio
SetMarcUnicodeFlag
SetUTF8Flag
);
+use C4::Languages;
use C4::Linker;
use C4::OAI::Sets;
use C4::Items qw( GetMarcItem );
use Koha::Logger;
use Koha::Caches;
+use Koha::ClassSources;
use Koha::Authority::Types;
use Koha::Acquisition::Currencies;
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
# update MARC subfield that stores biblioitems.cn_sort
_koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode );
- if (C4::Context->preference('BiblioAddsAuthorities')) {
+ if (C4::Context->preference('AutoLinkBiblios')) {
BiblioAutoLink( $record, $frameworkcode );
}
- # now add the record
- ModBiblioMarc( $record, $biblionumber, { skip_record_index => $skip_record_index } ) unless $defer_marc_save;
+ # now add the record, don't index while we are in the transaction though
+ ModBiblioMarc( $record, $biblionumber, { skip_record_index => 1 } ) unless $defer_marc_save;
# update OAI-PMH sets
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
_after_biblio_action_hooks({ action => 'create', biblio_id => $biblionumber });
logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
+
});
+ # We index now, after the transaction is committed
+ unless ( $skip_record_index ) {
+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
+ $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
+ }
} catch {
warn $_;
( $biblionumber, $biblioitemnumber ) = ( undef, undef );
logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $biblio->metadata->record->as_formatted );
}
- if ( !$options->{disable_autolink} && C4::Context->preference('BiblioAddsAuthorities') ) {
+ if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {
BiblioAutoLink( $record, $frameworkcode );
}
sub GetAuthorisedValueDesc {
my ( $tag, $subfield, $value, $framework, $tagslib, $category, $opac ) = @_;
+ return q{} unless defined($value);
+
+ my $cache = Koha::Caches->get_instance();
+ my $cache_key;
if ( !$category ) {
return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
#---- branch
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- my $branch = Koha::Libraries->find($value);
- return $branch? $branch->branchname: q{};
+ $cache_key = "libraries:name";
+ my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
+ if ( !$libraries ) {
+ $libraries = {
+ map { $_->branchcode => $_->branchname }
+ Koha::Libraries->search( {},
+ { columns => [ 'branchcode', 'branchname' ] } )
+ ->as_list
+ };
+ $cache->set_in_cache($cache_key, $libraries);
+ }
+ return $libraries->{$value};
}
#---- itemtypes
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
- my $itemtype = Koha::ItemTypes->find( $value );
- return $itemtype ? $itemtype->translated_description : q||;
+ my $lang = C4::Languages::getlanguage;
+ $lang //= 'en';
+ $cache_key = 'itemtype:description:' . $lang;
+ my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
+ if ( !$itypes ) {
+ $itypes =
+ { map { $_->itemtype => $_->translated_description }
+ Koha::ItemTypes->search()->as_list };
+ $cache->set_in_cache( $cache_key, $itypes );
+ }
+ return $itypes->{$value};
}
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
- my $source = GetClassSource($value);
- return $source ? $source->{description} : q||;
+ $cache_key = "cn_sources:description";
+ my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
+ if ( !$cn_sources ) {
+ $cn_sources = {
+ map { $_->cn_source => $_->description }
+ Koha::ClassSources->search( {},
+ { columns => [ 'cn_source', 'description' ] } )
+ ->as_list
+ };
+ $cache->set_in_cache($cache_key, $cn_sources);
+ }
+ return $cn_sources->{$value};
}
#---- "true" authorized value
my $dbh = C4::Context->dbh;
if ( $category ne "" ) {
- my $sth = $dbh->prepare( "SELECT lib, lib_opac FROM authorised_values WHERE category = ? AND authorised_value = ?" );
- $sth->execute( $category, $value );
- my $data = $sth->fetchrow_hashref;
- return ( $opac && $data->{'lib_opac'} ) ? $data->{'lib_opac'} : $data->{'lib'};
+ $cache_key = "AV_descriptions:" . $category;
+ my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
+ if ( !$av_descriptions ) {
+ $av_descriptions = {
+ map {
+ $_->authorised_value =>
+ { lib => $_->lib, lib_opac => $_->lib_opac }
+ } Koha::AuthorisedValues->search(
+ { category => $category },
+ {
+ columns => [ 'authorised_value', 'lib_opac', 'lib' ]
+ }
+ )->as_list
+ };
+ $cache->set_in_cache($cache_key, $av_descriptions);
+ }
+ return ( $opac && $av_descriptions->{$value}->{'lib_opac'} )
+ ? $av_descriptions->{$value}->{'lib_opac'}
+ : $av_descriptions->{$value}->{'lib'};
} else {
return $value; # if nothing is found return the original value
}
} else {
C4::Biblio::UpsertMarcSubfield($record, $biblioitem_tag, $biblioitem_subfield, $biblioitemnumber);
}
+
+ # update the control number (001) in MARC
+ if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){
+ unless($record->field('001')){
+ $record->insert_fields_ordered(MARC::Field->new('001', $biblionumber));
+ }
+ }
}
=head2 _koha_marc_update_biblioitem_cn_sort