From ca6c3c48d0480845d420a90874862ca27b289a93 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 27 Jan 2014 15:01:16 -0700 Subject: [PATCH] The gettext bind methods only need to be called once per page access This saves up to 40+ bindtextdomain()/bind_textdomain_codeset() calls per access. --- framework/Core/lib/Horde/Registry.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index d84b263f355..06b5e6fec38 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -124,6 +124,13 @@ class Horde_Registry implements Horde_Shutdown_Task */ protected $_args = array(); + /** + * Cached textdomain bindings. + * + * @var array + */ + protected $_bindCache = array(); + /** * Cached configuration information. * @@ -2705,12 +2712,17 @@ public function setLanguageEnvironment($lang = null, $app = null) */ public function setTextdomain($app, $directory) { - bindtextdomain($app, $directory); - textdomain($app); + if (isset($this->_bindCache[$app])) { + textdomain($app); + } else { + bindtextdomain($app, $directory); + textdomain($app); - /* The existence of this function depends on the platform. */ - if (function_exists('bind_textdomain_codeset')) { - bind_textdomain_codeset($app, 'UTF-8'); + /* The existence of this function depends on the platform. */ + if (function_exists('bind_textdomain_codeset')) { + bind_textdomain_codeset($app, 'UTF-8'); + } + $this->_bindCache[$app] = true; } }