From 89d0cd4591bb3146286c8206cc490d421496cf5f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 6 May 2015 15:57:03 +0000 Subject: [PATCH] adapt for change in R/O cache keys; handle difference in locale codes Signed-off-by: Galen Charlton --- Open-ILS/examples/apache/eg_startup.in | 2 +- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 17 +++++++++-------- Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Open-ILS/examples/apache/eg_startup.in b/Open-ILS/examples/apache/eg_startup.in index 94a97b5056..855159e16f 100755 --- a/Open-ILS/examples/apache/eg_startup.in +++ b/Open-ILS/examples/apache/eg_startup.in @@ -10,7 +10,7 @@ use OpenILS::WWW::AddedContent qw( @sysconfdir@/opensrf_core.xml ); use OpenILS::WWW::Proxy ('@sysconfdir@/opensrf_core.xml'); use OpenILS::WWW::Vandelay qw( @sysconfdir@/opensrf_core.xml ); use OpenILS::WWW::TemplateBatchBibUpdate qw( @sysconfdir@/opensrf_core.xml ); -use OpenILS::WWW::EGWeb ('@sysconfdir@/opensrf_core.xml', 'OpenILS::WWW::EGCatLoader', 'en-US');; +use OpenILS::WWW::EGWeb ('@sysconfdir@/opensrf_core.xml', 'OpenILS::WWW::EGCatLoader', 'en_us');; use OpenILS::WWW::IDL2js ('@sysconfdir@/opensrf_core.xml'); use OpenILS::WWW::FlatFielder; use OpenILS::WWW::PhoneList ('@sysconfdir@/opensrf_core.xml'); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 7ab69a3623..daff018361 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -28,7 +28,7 @@ our %cache = ( # cached data sub child_init { my $class = shift; my $e = shift; - my @locales = @_; + my %locales = @_; # create a stub object with just enough in place # to call init_ro_object_cache() @@ -37,18 +37,18 @@ sub child_init { $stub->editor($e); $stub->ctx($ctx); - $stub->init_ro_object_cache(); - foreach my $locale (@locales) { + foreach my $locale (sort keys %locales) { + OpenSRF::AppSession->default_locale($locales{$locale}); $ctx->{locale} = $locale; - OpenSRF::AppSession->default_locale($locale); + $stub->init_ro_object_cache(); # pre-cache various sets of objects # known to be time-consuming to retrieve # the first go around - $ro_object_subs->{aou_tree}(); - $ro_object_subs->{aouct_tree}(); - $ro_object_subs->{get_ccvm}(); - $ro_object_subs->{get_authority_fields}(1); + $ro_object_subs->{$locale}->{aou_tree}(); + $ro_object_subs->{$locale}->{aouct_tree}(); + $ro_object_subs->{$locale}->{ccvm_list}(); + $ro_object_subs->{$locale}->{get_authority_fields}(1); } } @@ -99,6 +99,7 @@ sub init_ro_object_cache { $cache{map}{$hint} = {}; $locale_subs->{$get_key} = sub { my $id = shift; + warn "my hint is $hint for $id"; return $cache{map}{$locale}{$hint}{$id} if $cache{map}{$locale}{$hint}{$id}; ($cache{map}{$locale}{$hint}{$id}) = grep { $_->$ident_field eq $id } @{$locale_subs->{$list_key}->()}; return $cache{map}{$locale}{$hint}{$id}; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index 44d6f93b58..2bc190f849 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -27,12 +27,13 @@ my %vhost_processor_cache; my $bootstrap_config; my @context_loaders_to_preinit = (); -my @locales_to_preinit = (); +my %locales_to_preinit = (); sub import { my ($self, $bootstrap_config, $loaders, $locales) = @_; @context_loaders_to_preinit = split /\s+/, $loaders, -1 if defined($loaders); - @locales_to_preinit = split /\s+/, $locales, -1 if defined($locales); + %locales_to_preinit = map { $_ => parse_eg_locale($_) } + split /\s+/, $locales, -1 if defined($locales); } sub child_init { @@ -44,7 +45,7 @@ sub child_init { foreach my $loader (@context_loaders_to_preinit) { eval { $loader->use; - $loader->child_init($e, @locales_to_preinit); + $loader->child_init($e, %locales_to_preinit); }; } return Apache2::Const::OK; -- 2.11.0