added caching of results of GetMarcStructure
authorGalen Charlton <galen.charlton@liblime.com>
Mon, 21 Jan 2008 20:14:41 +0000 (14:14 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 22 Jan 2008 13:23:35 +0000 (07:23 -0600)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm

index 96a7c5b..e992df9 100755 (executable)
@@ -576,10 +576,19 @@ $frameworkcode : the framework code to read
 
 =cut
 
+# cache for results of GetMarcStructure -- needed
+# for batch jobs
+our $marc_structure_cache;
+
 sub GetMarcStructure {
     my ( $forlibrarian, $frameworkcode ) = @_;
     my $dbh=C4::Context->dbh;
     $frameworkcode = "" unless $frameworkcode;
+
+    if (defined $marc_structure_cache and exists $marc_structure_cache->{$forlibrarian}->{$frameworkcode}) {
+        return $marc_structure_cache->{$forlibrarian}->{$frameworkcode};
+    }
+
     my $sth;
     my $libfield = ( $forlibrarian eq 1 ) ? 'liblibrarian' : 'libopac';
 
@@ -659,6 +668,9 @@ sub GetMarcStructure {
         $res->{$tag}->{$subfield}->{'link'}           = $link;
         $res->{$tag}->{$subfield}->{defaultvalue}     = $defaultvalue;
     }
+
+    $marc_structure_cache->{$forlibrarian}->{$frameworkcode} = $res;
+
     return $res;
 }