Bugzilla – Attachment 33116 Details for
Bug 13169
C4::Templates::themelanguage fails if the DB is not populated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 13169: C4::Templates::themelanguage fails if the DB is not populated
PASSED-QA-Bug-13169-C4Templatesthemelanguage-fails.patch (text/plain), 3.78 KB, created by
Katrin Fischer
on 2014-11-01 08:59:37 UTC
(
hide
)
Description:
[PASSED QA] Bug 13169: C4::Templates::themelanguage fails if the DB is not populated
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-11-01 08:59:37 UTC
Size:
3.78 KB
patch
obsolete
>From edbbb0e5b1e54335b2ca7c6d78edb05af43a7c0f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Fri, 31 Oct 2014 11:00:22 -0300 >Subject: [PATCH] [PASSED QA] Bug 13169: C4::Templates::themelanguage fails if > the DB is not populated > >With the aim to remove hardcoded themes the C4::Templates::themelanguage >got dependent on the DB being populated. This patch reintroduced the >hardcoded defaults as a last resort. > >To test: >- Do a fresh install, clean your browser's cache, empty DB >- Open the staff interface >=> FAIL: A "Software error" screen shows "Template process failed: file error..." >- Apply the patch >- Reload >=> SUCCESS: The webinstaller prompts for login correctly. >- Sign off :-D > >Regards > >Signed-off-by: Nick Clemens <nick@quecheelibrary.org> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Templates.pm | 40 +++++++++++++++++++++++++++++++--------- > 1 file changed, 31 insertions(+), 9 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index 7d09a58..3a3a65c 100644 >--- a/C4/Templates.pm >+++ b/C4/Templates.pm >@@ -4,7 +4,7 @@ use strict; > use warnings; > use Carp; > use CGI; >-use List::MoreUtils qw/any/; >+use List::MoreUtils qw/any uniq/; > > # Copyright 2009 Chris Cormack and The Koha Dev Team > # >@@ -250,9 +250,20 @@ sub gettemplate { > } > > >-#--------------------------------------------------------------------------------------------------------- >-# FIXME - POD >-# FIXME - Rewritten to remove hardcoded theme with minimal changes, need to be rethinked >+=head2 themelanguage >+ >+ my ($theme,$lang,\@themes) = themelanguage($htdocs,$tmpl,$interface,query); >+ >+This function returns the theme and language to be used for rendering the UI. >+It also returns the list of themes that should be applied as a fallback. This is >+used for the theme overlay feature (i.e. if a file doesn't exist on the requested >+theme, fallback to the configured fallback). >+ >+Important: this function is used on the webinstaller too, so always consider >+the use case where the DB is not populated already when rewriting/fixing. >+ >+=cut >+ > sub themelanguage { > my ($htdocs, $tmpl, $interface, $query) = @_; > ($query) or warn "no query in themelanguage"; >@@ -261,20 +272,31 @@ sub themelanguage { > my $lang = C4::Languages::getlanguage($query); > > # Get theme >- my @themes = ( C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'opacthemes' ) ); >- my $fallback = C4::Context->preference( ($interface eq 'intranet') ? 'template' : 'OPACFallback' ); >- push @themes, $fallback; >+ my @themes; >+ my $theme_syspref = ($interface eq 'intranet') ? 'template' : 'opacthemes'; >+ my $fallback_syspref = ($interface eq 'intranet') ? 'template' : 'OPACFallback'; >+ # Yeah, hardcoded, last resort if the DB is not populated >+ my $hardcoded_theme = ($interface eq 'intranet') ? 'prog' : 'bootstrap'; >+ >+ # Configured theme is the first one >+ push @themes, C4::Context->preference( $theme_syspref ) >+ if C4::Context->preference( $theme_syspref ); >+ # Configured fallback next >+ push @themes, C4::Context->preference( $fallback_syspref ) >+ if C4::Context->preference( $fallback_syspref ); >+ # The hardcoded fallback theme is the last one >+ push @themes, $hardcoded_theme; > > # Try to find first theme for the selected theme/lang, then for fallback/lang > for my $theme (@themes) { > if ( -e "$htdocs/$theme/$lang/modules/$tmpl" ) { >- return ($theme, $lang, \@themes); >+ return ( $theme, $lang, uniq( \@themes ) ); > } > } > # Otherwise return theme/'en', last resort fallback/'en' > for my $theme (@themes) { > if ( -e "$htdocs/$theme/en/modules/$tmpl" ) { >- return ($theme, 'en', \@themes); >+ return ( $theme, 'en', uniq( \@themes ) ); > } > } > } >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13169
:
33073
|
33115
| 33116