From d5ee989859275f066c6240b6f4258cb92be25a74 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 28 Apr 2009 15:56:04 +0000 Subject: [PATCH] "- caching loginscreen+mainscreen messages instance (NOT tree) specific - invalidating the cache also for translation::write (to be able to update the loginscreen message)" --- phpgwapi/inc/class.translation.inc.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 32e04d931b..c4bb56a4aa 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -93,6 +93,13 @@ class translation */ static $mbstring_internal_encoding; + /** + * Application which translations have to be cached instance- and NOT tree-specific + * + * @var array + */ + static $instance_specific_translations = array('loginscreen','mainscreen'); + /** * returns the charset to use (!$lang) or the charset of the lang-files or $lang * @@ -242,7 +249,9 @@ class translation if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang) { //$start = microtime(true); - $loaded =& egw_cache::getTree(__CLASS__,$app.':'.$lang,__CLASS__.'::load_app',array($app,$lang)); + // for loginscreen we have to use a instance specific cache! + $loaded =& egw_cache::getCache(in_array($app,self::$instance_specific_translations) ? egw_cache::INSTANCE : egw_cache::TREE, + __CLASS__,$app.':'.$lang,__CLASS__.'::load_app',array($app,$lang)); self::$lang_arr = self::$lang_arr ? array_merge(self::$lang_arr,$loaded) : $loaded; self::$loaded_apps[$app] = $lang; @@ -868,19 +877,22 @@ class translation * insert/update one phrase in the lang-table * * @param string $lang - * @param string $app_name + * @param string $app * @param string $message_id * @param string $content */ - static function write($lang,$app_name,$message_id,$content) + static function write($lang,$app,$message_id,$content) { self::$db->insert(self::LANG_TABLE,array( 'content' => $content, ),array( 'lang' => $lang, - 'app_name' => $app_name, + 'app_name' => $app, 'message_id' => $message_id, ),__LINE__,__FILE__); + + // invalidate the cache + egw_cache::unsetCache(in_array($app,self::$instance_specific_translations) ? egw_cache::INSTANCE : egw_cache::TREE,__CLASS__,$app.':'.$lang); } /**