From 86f448f0ee48a31742e217a791c8d5c0026015c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Thu, 7 May 2009 19:28:33 +0200 Subject: [PATCH] Optimize XSLT.pm Avoid reading marc_tag_structure for each biblo record to transform by XSLT. Not totaly useless on OPAC result page. Should be done via application variables rather than request variable, but this is another story. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/XSLT.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 0fbfda159b..8c576b338c 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -94,16 +94,27 @@ sub transformMARCXML4XSLT { =cut +# Cache for tagfield-tagsubfield to decode per framework. +# Should be preferably be placed in Koha-core... +my %authval_per_framework; + sub getAuthorisedValues4MARCSubfields { my ($frameworkcode) = @_; - my @results; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT DISTINCT tagfield,tagsubfield FROM marc_subfield_structure WHERE authorised_value IS NOT NULL AND authorised_value!='' AND frameworkcode=?"); - $sth->execute($frameworkcode); - while (my $result = $sth->fetchrow_hashref()) { - push @results, $result; + unless ( $authval_per_framework{ $frameworkcode } ) { + my @results; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT DISTINCT tagfield, tagsubfield + FROM marc_subfield_structure + WHERE authorised_value IS NOT NULL + AND authorised_value!='' + AND frameworkcode=?"); + $sth->execute( $frameworkcode ); + while ( my $result = $sth->fetchrow_hashref() ) { + push ( @results, $result ); + } + $authval_per_framework{ $frameworkcode } = \@results; } - return \@results; + return $authval_per_framework{ $frameworkcode }; } my $stylesheet; -- 2.20.1