@@ -, +, @@ Koha/Template/Plugins/Branches.pm to improve performance --- Koha/Template/Plugin/Branches.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) --- a/Koha/Template/Plugin/Branches.pm +++ a/Koha/Template/Plugin/Branches.pm @@ -30,8 +30,11 @@ use Koha::Libraries; sub GetName { my ( $self, $branchcode ) = @_; - my $l = Koha::Libraries->find($branchcode); - return $l ? $l->branchname : q{}; + unless (exists $self->{branches}->{$branchcode} ){ + my $l = Koha::Libraries->find($branchcode); + $self->{branches}->{$branchcode} = $l if $l; + } + return $self->{branches}->{$branchcode}->branchname ? $self->{branchname}->{$branchcode} : q{}; } sub GetLoggedInBranchcode { @@ -49,11 +52,11 @@ sub GetLoggedInBranchname { sub GetURL { my ( $self, $branchcode ) = @_; - my $query = "SELECT branchurl FROM branches WHERE branchcode = ?"; - my $sth = C4::Context->dbh->prepare($query); - $sth->execute($branchcode); - my $b = $sth->fetchrow_hashref(); - return $b->{branchurl}; + unless (exists $self->{branches}->{$branchcode} ){ + my $l = Koha::Libraries->find($branchcode); + $self->{branches}->{$branchcode} = $l if $l; + } + return $self->{branches}->{$branchcode}->branchurl ? $self->{branchname}->{$branchcode} : q{}; } sub all { --