Bug 20116: Flush the caches
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 16 May 2018 20:26:09 +0000 (17:26 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 17 Apr 2020 08:23:21 +0000 (09:23 +0100)
When languages are added or removed when need to flush the caches to
keep the interface consistent

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

debian/scripts/koha-translate
misc/bin/clear_cache.pl [new file with mode: 0755]
misc/translator/translate

index c7bd82c..8b9c6b6 100755 (executable)
@@ -231,6 +231,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=""
@@ -298,11 +307,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 (executable)
index 0000000..3643d32
--- /dev/null
@@ -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;
index bab716d..f53dd46 100755 (executable)
@@ -29,6 +29,8 @@ use LangInstaller;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Caches;
+
 
 my $verbose     = 0;
 my $pref        = 0;
@@ -68,6 +70,8 @@ if ( $cmd =~ /^(create|install|update|compress|uncompress)$/ ) {
     else {
         $installer->$cmd(\@files);
     }
+
+    Koha::Caches->get_instance()->flush_all if $cmd ne 'update';
 }
 else {
     usage();