From 0efa708beb3fcd14413d4ec6d84fbdea76904881 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 20 Jul 2017 11:00:42 +0100 Subject: Cache template paths in About.pm with lang_code Fixes #1765 --- perllib/FixMyStreet/App/Controller/About.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/perllib/FixMyStreet/App/Controller/About.pm b/perllib/FixMyStreet/App/Controller/About.pm index 78e548c5f..233da25d3 100755 --- a/perllib/FixMyStreet/App/Controller/About.pm +++ b/perllib/FixMyStreet/App/Controller/About.pm @@ -34,22 +34,24 @@ sub index : Path("/about") : Args(0) { sub find_template : Private { my ( $self, $c, $page ) = @_; - return $found{$page} if !FixMyStreet->config('STAGING_SITE') && exists $found{$page}; - my $lang_code = $c->stash->{lang_code}; + + return $found{$lang_code}{$page} if !FixMyStreet->config('STAGING_SITE') && + exists $found{$lang_code}{$page}; + foreach my $dir_templates (@{$c->stash->{additional_template_paths}}, @{$c->view('Web')->paths}) { foreach my $dir_static (static_dirs($page, $dir_templates)) { foreach my $file ("$page-$lang_code.html", "$page.html") { if (-e "$dir_templates/$dir_static/$file") { - $found{$page} = "$dir_static/$file"; - return $found{$page}; + $found{$lang_code}{$page} = "$dir_static/$file"; + return $found{$lang_code}{$page}; } } } } # Cache that the page does not exist, so we don't look next time - $found{$page} = undef; - return $found{$page}; + $found{$lang_code}{$page} = undef; + return $found{$lang_code}{$page}; } sub static_dirs { -- cgit v1.2.3