Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benakamoorthi@fastmail.fm>2014-03-22 11:01:19 +0400
committerdiosmosis <benakamoorthi@fastmail.fm>2014-03-22 11:33:50 +0400
commit3c119c8416b27a83d543e8b3cf0f5ffea932712f (patch)
tree48aecfb6383722be3d2c6ad5067521597c80ef72
parent4a03941a576937aba15b0f2f9786bcd8d86248d5 (diff)
Do not use static variables for config paths since they can now be specified upon construction.
-rw-r--r--core/Config.php49
-rw-r--r--plugins/Installation/Controller.php2
-rw-r--r--tests/PHPUnit/TestingEnvironment.php16
3 files changed, 46 insertions, 21 deletions
diff --git a/core/Config.php b/core/Config.php
index 4d0c4d9a65..eae234041e 100644
--- a/core/Config.php
+++ b/core/Config.php
@@ -40,9 +40,9 @@ use Exception;
*/
class Config extends Singleton
{
- public static $defaultLocalConfigPath = '/config/config.ini.php';
- public static $defaultCommonConfigPath = '/config/common.config.ini.php';
- public static $defaultGlobalConfigPath = '/config/global.ini.php';
+ const DEFAULT_LOCAL_CONFIG_PATH = '/config/config.ini.php';
+ const DEFAULT_COMMON_CONFIG_PATH = '/config/common.config.ini.php';
+ const DEFAULT_GLOBAL_CONFIG_PATH = '/config/global.ini.php';
/**
* Contains configuration files values
@@ -59,6 +59,11 @@ class Config extends Singleton
protected $pathLocal = null;
/**
+ * @var boolean
+ */
+ protected $isTest = false;
+
+ /**
* Constructor
*/
public function __construct($pathGlobal = null, $pathLocal = null, $pathCommon = null)
@@ -69,9 +74,34 @@ class Config extends Singleton
}
/**
- * @var boolean
+ * Returns the path to the local config file used by this instance.
+ *
+ * @return string
*/
- protected $isTest = false;
+ public function getLocalPath()
+ {
+ return $this->pathLocal;
+ }
+
+ /**
+ * Returns the path to the global config file used by this instance.
+ *
+ * @return string
+ */
+ public function getGlobalPath()
+ {
+ return $this->pathGlobal;
+ }
+
+ /**
+ * Returns the path to the common config file used by this instance.
+ *
+ * @return string
+ */
+ public function getCommonPath()
+ {
+ return $this->pathCommon;
+ }
/**
* Enable test environment
@@ -137,7 +167,7 @@ class Config extends Singleton
*/
protected static function getGlobalConfigPath()
{
- return PIWIK_USER_PATH . self::$defaultGlobalConfigPath;
+ return PIWIK_USER_PATH . self::DEFAULT_GLOBAL_CONFIG_PATH;
}
/**
@@ -147,7 +177,7 @@ class Config extends Singleton
*/
public static function getCommonConfigPath()
{
- return PIWIK_USER_PATH . self::$defaultCommonConfigPath;
+ return PIWIK_USER_PATH . self::DEFAULT_COMMON_CONFIG_PATH;
}
/**
@@ -161,7 +191,7 @@ class Config extends Singleton
if ($path) {
return $path;
}
- return PIWIK_USER_PATH . self::$defaultLocalConfigPath;
+ return PIWIK_USER_PATH . self::DEFAULT_LOCAL_CONFIG_PATH;
}
private static function getLocalConfigInfoForHostname($hostname)
@@ -351,7 +381,8 @@ class Config extends Singleton
// must be called here, not in init(), since setTestEnvironment() calls init(). (this avoids
// infinite recursion)
- Piwik::postTestEvent('Config.createConfigSingleton', array( $this, &$this->configCache ));
+ Piwik::postTestEvent('Config.createConfigSingleton',
+ array($this, &$this->configCache, &$this->configLocal));
}
// check cache for merged section
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index fd4e91642e..11b5f30b26 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -1086,7 +1086,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
private function isFinishedInstallation()
{
- $isConfigFileFound = file_exists(Config::getLocalConfigPath());
+ $isConfigFileFound = file_exists(Config::getInstance()->getLocalPath());
if (!$isConfigFileFound) {
return false;
diff --git a/tests/PHPUnit/TestingEnvironment.php b/tests/PHPUnit/TestingEnvironment.php
index 2332c068e4..23de01e8e2 100644
--- a/tests/PHPUnit/TestingEnvironment.php
+++ b/tests/PHPUnit/TestingEnvironment.php
@@ -85,17 +85,11 @@ class Piwik_TestingEnvironment
{
$testingEnvironment = new Piwik_TestingEnvironment();
- if ($testingEnvironment->configFileLocal) {
- \Piwik\Config::$defaultLocalConfigPath = $testingEnvironment->configFileLocal;
- }
-
- if ($testingEnvironment->configFileCommon) {
- \Piwik\Config::$defaultCommonConfigPath = $testingEnvironment->configFileCommon;
- }
-
- if ($testingEnvironment->configFileGlobal) {
- \Piwik\Config::$defaultGlobalConfigPath = $testingEnvironment->configFileGlobal;
- }
+ Config::setSingletonInstance(new Config(
+ $testingEnvironment->configFileGlobal,
+ $testingEnvironment->configFileLocal,
+ $testingEnvironment->configFileCommon
+ ));
if ($testingEnvironment->queryParamOverride) {
foreach ($testingEnvironment->queryParamOverride as $key => $value) {