Bug 32426: (follow-up) Fix api/v1/patrons.t
[srvgit] / C4 / Biblio.pm
index 991d327..7a49f47 100644 (file)
@@ -287,8 +287,8 @@ sub AddBiblio {
                 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")) {
@@ -298,7 +298,13 @@ sub AddBiblio {
             _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 );
@@ -1375,6 +1381,8 @@ descriptions rather than normal ones when they exist.
 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 ) {
@@ -1383,7 +1391,7 @@ sub GetAuthorisedValueDesc {
 
         #---- branch
         if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
-            $cache_key = "LibraryNames";
+            $cache_key = "libraries:name";
             my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
             if ( !$libraries ) {
                 $libraries = {
@@ -1401,7 +1409,7 @@ sub GetAuthorisedValueDesc {
         if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
             my $lang = C4::Languages::getlanguage;
             $lang //= 'en';
-            $cache_key = $lang . 'ItemTypeDescriptions';
+            $cache_key = 'itemtype:description:' . $lang;
             my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
             if ( !$itypes ) {
                 $itypes =
@@ -1413,7 +1421,7 @@ sub GetAuthorisedValueDesc {
         }
 
         if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
-            $cache_key = "ClassSources";
+            $cache_key = "cn_sources:description";
             my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
             if ( !$cn_sources ) {
                 $cn_sources = {
@@ -1433,7 +1441,7 @@ sub GetAuthorisedValueDesc {
 
     my $dbh = C4::Context->dbh;
     if ( $category ne "" ) {
-        $cache_key = "AVDescriptions-" . $category;
+        $cache_key = "AV_descriptions:" . $category;
         my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
         if ( !$av_descriptions ) {
             $av_descriptions = {