diff options
author | diosmosis <benaka@piwik.pro> | 2015-04-07 08:24:14 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-04-07 08:24:14 +0300 |
commit | f392b596313cb2397f470916f5928ae79eaee0ec (patch) | |
tree | c08fc2a06ac2924b6f0d94d7fb6692267f55d77d /core/Config.php | |
parent | 0dc0ba95ea52a5fac46dadfbda70709802a2703c (diff) |
Adding environment validation class to centralize all config.ini.php + related file checking (both in code & in time (so done in one place in code & one time in execution)).
Diffstat (limited to 'core/Config.php')
-rw-r--r-- | core/Config.php | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/core/Config.php b/core/Config.php index 5a9b7852f7..42cec66702 100644 --- a/core/Config.php +++ b/core/Config.php @@ -14,8 +14,6 @@ use Piwik\Application\Kernel\GlobalSettingsProvider; use Piwik\Application\Kernel\GlobalSettingsProvider\IniSettingsProvider; use Piwik\Config\IniFileChain; use Piwik\Config\ConfigNotFoundException; -use Piwik\Config\IniFileChainFactory; -use Piwik\Container\StaticContainer; use Piwik\Ini\IniReadingException; /** @@ -290,7 +288,6 @@ class Config extends Singleton $this->reload(); } catch (Exception $ex) { // pass (not required for local file to exist at this point) - // TODO: debug log } return $this->pathLocal; @@ -337,29 +334,12 @@ class Config extends Singleton { $this->initialized = false; - $inTrackerRequest = SettingsServer::isTrackerApiRequest(); - - // read defaults from global.ini.php - if (!is_readable($this->pathGlobal) && $inTrackerRequest) { - throw new Exception(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathGlobal))); - } - - try { - // Force a reload because maybe the files to use were overridden in the Config's constructor - $this->settings->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal); - } catch (IniReadingException $e) { - // TODO why a different behavior here? This needs a comment - if ($inTrackerRequest) { - throw $e; - } - } - - // Check config.ini.php last - if (!$inTrackerRequest) { - $this->checkLocalConfigFound(); - } + $this->settings->reload(array($this->pathGlobal, $this->pathCommon), $this->pathLocal); } + /** + * @deprecated + */ public function existsLocalConfig() { return is_readable($this->pathLocal); @@ -371,12 +351,12 @@ class Config extends Singleton unlink($configLocal); } - public function checkLocalConfigFound() +/* public function checkLocalConfigFound() { if (!$this->existsLocalConfig()) { throw new ConfigNotFoundException(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathLocal))); } - } + }*/ /** * Decode HTML entities @@ -435,9 +415,9 @@ class Config extends Singleton // this is done lazily and not in __construct so Installation will properly be triggered. ideally, it should be // done in __construct, but the exception that is thrown depends on Translator which depends on Config. the // circular dependency causes problems. - if (!SettingsServer::isTrackerApiRequest()) { + /*if (!SettingsServer::isTrackerApiRequest()) { $this->checkLocalConfigFound(); - } + }*/ $this->postConfigTestEvent(); } |