diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-20 03:08:33 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-20 03:08:33 +0300 |
commit | 8c9214c0ef73e268834d7e016029621ae2a9f1b7 (patch) | |
tree | 157e6d678371c1e8bcfd3ca95ae4658c241de13a | |
parent | aead5ce7f2ab61c786799a411cdc69120fe4550e (diff) |
Fix two regressions where language would not change in installer, and where language would reset to english in the middle of the install process.
-rw-r--r-- | plugins/Installation/Controller.php | 17 | ||||
-rw-r--r-- | plugins/LanguagesManager/LanguagesManager.php | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 9976f4ad58..cdce51d111 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -13,6 +13,7 @@ use Piwik\Access; use Piwik\AssetManager; use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Db; use Piwik\Db\Adapter; @@ -31,6 +32,7 @@ use Piwik\Plugins\UsersManager\API as APIUsersManager; use Piwik\ProxyHeaders; use Piwik\SettingsPiwik; use Piwik\Tracker\TrackerCodeGenerator; +use Piwik\Translation\Translator; use Piwik\Updater; use Piwik\Url; use Piwik\Version; @@ -547,6 +549,17 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $config->forceSave(); + + // re-save the currently viewed language (since we saved the config file, there is now a salt which makes the + // existing session cookie invalid) + $this->resetLanguageCookie(); + } + + private function resetLanguageCookie() + { + /** @var Translator $translator */ + $translator = StaticContainer::get('Piwik\Translation\Translator'); + LanguagesManager::setLanguageForSession($translator->getCurrentLanguage()); } private function checkPiwikIsNotInstalled() @@ -675,6 +688,10 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $config = Config::getInstance(); if ($config->existsLocalConfig()) { $config->deleteLocalConfig(); + + // deleting the config file removes the salt, which in turns invalidates existing cookies (including the + // one for selected language), so we re-save that cookie now + $this->resetLanguageCookie(); } } diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 9c977d2bab..4b881caf24 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -34,6 +34,7 @@ class LanguagesManager extends \Piwik\Plugin return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', + 'Config.NoConfigurationFile' => 'initLanguage', 'Request.dispatchCoreAndPluginUpdatesScreen' => 'initLanguage', 'Platform.initialized' => 'initLanguage', 'UsersManager.deleteUser' => 'deleteUserLanguage', |