From 105b89a8e855cb0e7f5a832d7f461a7670690347 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 May 2018 17:26:09 -0300 Subject: [PATCH] Bug 20116: Flush the caches When languages are added or removed when need to flush the caches to keep the interface consistent --- debian/scripts/koha-translate | 17 +++++++++++++++-- misc/bin/clear_cache.pl | 9 +++++++++ misc/translator/translate | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 misc/bin/clear_cache.pl diff --git a/debian/scripts/koha-translate b/debian/scripts/koha-translate index 91f59e9498..7e5bf14a91 100755 --- a/debian/scripts/koha-translate +++ b/debian/scripts/koha-translate @@ -232,6 +232,15 @@ init_template_paths() PO_DIR="$TRANSLATE_DIR/po" } +flush_cache() +{ + if [ "$dev" = "" ]; then + koha-foreach --enabled "$KOHA_HOME/misc/bin/clear_cache.pl" + else + koha-shell $dev -c "$KOHA_HOME/misc/bin/clear_cache.pl" + fi +} + # Control variables list_all="" op="" @@ -299,11 +308,15 @@ case $op in "list") list $list_all ;; "install") - install_lang $language ;; + install_lang $language + flush_cache + ;; "update") update_lang $language ;; "remove") - remove_lang $language ;; + remove_lang $language + flush_cache + ;; "check") check_lang_po_files $language ;; *) diff --git a/misc/bin/clear_cache.pl b/misc/bin/clear_cache.pl new file mode 100755 index 0000000000..3643d3273c --- /dev/null +++ b/misc/bin/clear_cache.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl -w + +use Modern::Perl; +use Koha::Caches; + +# Could take parameters to be less rude +Koha::Caches->get_instance()->flush_all; +Koha::Caches->get_instance('config')->flush_all; +Koha::Caches->get_instance('sysprefs')->flush_all; diff --git a/misc/translator/translate b/misc/translator/translate index 697a3db14a..33151601e1 100755 --- a/misc/translator/translate +++ b/misc/translator/translate @@ -26,6 +26,8 @@ use LangInstaller; use Getopt::Long; use Pod::Usage; +use Koha::Caches; + my $verbose = 0; my $pref = 0; @@ -65,6 +67,8 @@ if ( $cmd =~ /create|install|update/ ) { else { $installer->$cmd(\@files); } + + Koha::Caches->get_instance()->flush_all if $cmd ne 'update'; } else { usage(); -- 2.11.0