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
path: root/core
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-05-19 07:30:42 +0400
committermattab <matthieu.aubry@gmail.com>2014-05-19 07:30:42 +0400
commite620f0ba6d80381d896d5e6a06cb35a345a3cf37 (patch)
tree2468f7c594736a17372ad316047f491eda340cba /core
parent5161aaaecc7c074827364ec2a537e0ddf325ac44 (diff)
Fixes #5181 Renamed method
Diffstat (limited to 'core')
-rw-r--r--core/AssetManager.php2
-rw-r--r--core/CacheFile.php2
-rw-r--r--core/CliMulti.php2
-rw-r--r--core/Db/BatchInsert.php2
-rw-r--r--core/Filechecks.php2
-rw-r--r--core/Log.php2
-rw-r--r--core/ReportRenderer.php2
-rw-r--r--core/Session.php4
-rw-r--r--core/SettingsPiwik.php45
-rwxr-xr-xcore/Twig.php2
-rw-r--r--core/Url.php7
11 files changed, 45 insertions, 27 deletions
diff --git a/core/AssetManager.php b/core/AssetManager.php
index 90185a43f3..4a0de2e3b0 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -253,7 +253,7 @@ class AssetManager extends Singleton
public function getAssetDirectory()
{
$mergedFileDirectory = PIWIK_USER_PATH . "/tmp/assets";
- $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithHostname($mergedFileDirectory);
+ $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithInstanceId($mergedFileDirectory);
if (!is_dir($mergedFileDirectory)) {
Filesystem::mkdir($mergedFileDirectory);
diff --git a/core/CacheFile.php b/core/CacheFile.php
index 043770b3db..5d9000332f 100644
--- a/core/CacheFile.php
+++ b/core/CacheFile.php
@@ -43,7 +43,7 @@ class CacheFile
public function __construct($directory, $timeToLiveInSeconds = 300)
{
$cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/';
- $this->cachePath = SettingsPiwik::rewriteTmpPathWithHostname($cachePath);
+ $this->cachePath = SettingsPiwik::rewriteTmpPathWithInstanceId($cachePath);
if ($timeToLiveInSeconds < self::MINIMUM_TTL) {
$timeToLiveInSeconds = self::MINIMUM_TTL;
diff --git a/core/CliMulti.php b/core/CliMulti.php
index cb53c4ed4a..740528ecb3 100644
--- a/core/CliMulti.php
+++ b/core/CliMulti.php
@@ -203,7 +203,7 @@ class CliMulti {
public static function getTmpPath()
{
$dir = PIWIK_INCLUDE_PATH . '/tmp/climulti';
- return SettingsPiwik::rewriteTmpPathWithHostname($dir);
+ return SettingsPiwik::rewriteTmpPathWithInstanceId($dir);
}
private function findPhpBinary()
diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php
index 659954d06a..3a05e516d6 100644
--- a/core/Db/BatchInsert.php
+++ b/core/Db/BatchInsert.php
@@ -59,7 +59,7 @@ class BatchInsert
public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
{
$filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
- $filePath = SettingsPiwik::rewriteTmpPathWithHostname($filePath);
+ $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
$loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
diff --git a/core/Filechecks.php b/core/Filechecks.php
index 52cb995bad..7bbf0f1162 100644
--- a/core/Filechecks.php
+++ b/core/Filechecks.php
@@ -44,7 +44,7 @@ class Filechecks
}
if(strpos($directoryToCheck, '/tmp/') !== false) {
- $directoryToCheck = SettingsPiwik::rewriteTmpPathWithHostname($directoryToCheck);
+ $directoryToCheck = SettingsPiwik::rewriteTmpPathWithInstanceId($directoryToCheck);
}
Filesystem::mkdir($directoryToCheck);
diff --git a/core/Log.php b/core/Log.php
index 09d548a7f0..ab4093cb5f 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -323,7 +323,7 @@ class Log extends Singleton
) {
$logPath = PIWIK_USER_PATH . DIRECTORY_SEPARATOR . $logPath;
}
- $logPath = SettingsPiwik::rewriteTmpPathWithHostname($logPath);
+ $logPath = SettingsPiwik::rewriteTmpPathWithInstanceId($logPath);
if (is_dir($logPath)) {
$logPath .= '/piwik.log';
}
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index 4634f9197c..42a5f72570 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -144,7 +144,7 @@ abstract class ReportRenderer
protected static function getOutputPath($filename)
{
$outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
- $outputFilename = SettingsPiwik::rewriteTmpPathWithHostname($outputFilename);
+ $outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
@chmod($outputFilename, 0600);
@unlink($outputFilename);
diff --git a/core/Session.php b/core/Session.php
index b2e91f7e68..7cf8ab4f9c 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -122,7 +122,7 @@ class Session extends Zend_Session
}
$pathToSessions = Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/');
- $pathToSessions = SettingsPiwik::rewriteTmpPathWithHostname($pathToSessions);
+ $pathToSessions = SettingsPiwik::rewriteTmpPathWithInstanceId($pathToSessions);
$message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>",
Piwik::translate('General_ExceptionUnableToStartSession'),
$pathToSessions,
@@ -142,7 +142,7 @@ class Session extends Zend_Session
public static function getSessionsDirectory()
{
$path = PIWIK_USER_PATH . '/tmp/sessions';
- return SettingsPiwik::rewriteTmpPathWithHostname($path);
+ return SettingsPiwik::rewriteTmpPathWithInstanceId($path);
}
public static function close()
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index 723ea065dc..61b27607e3 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -257,15 +257,23 @@ class SettingsPiwik
}
/**
+ * @deprecated Use SettingsPiwik::rewriteTmpPathWithInstanceId instead
+ */
+ public static function rewriteTmpPathWithHostname($path)
+ {
+ return self::rewriteTmpPathWithInstanceId($path);
+ }
+
+ /**
* If Piwik uses per-domain config file, also make tmp/ folder per-domain
* @param $path
* @return string
* @throws \Exception
*/
- public static function rewriteTmpPathWithHostname($path)
+ public static function rewriteTmpPathWithInstanceId($path)
{
$tmp = '/tmp/';
- $path = self::rewritePathAppendHostname($path, $tmp);
+ $path = self::rewritePathAppendPiwikInstanceId($path, $tmp);
return $path;
}
@@ -274,10 +282,10 @@ class SettingsPiwik
* @param $path
* @return mixed
*/
- public static function rewriteMiscUserPathWithHostname($path)
+ public static function rewriteMiscUserPathWithInstanceId($path)
{
$tmp = 'misc/user/';
- $path = self::rewritePathAppendHostname($path, $tmp);
+ $path = self::rewritePathAppendPiwikInstanceId($path, $tmp);
return $path;
}
@@ -345,10 +353,10 @@ class SettingsPiwik
* @return mixed
* @throws \Exception
*/
- protected static function rewritePathAppendHostname($pathToRewrite, $leadingPathToAppendHostnameTo)
+ protected static function rewritePathAppendPiwikInstanceId($pathToRewrite, $leadingPathToAppendHostnameTo)
{
- $hostname = self::getConfigHostname();
- if (empty($hostname)) {
+ $instanceId = self::getPiwikInstanceId();
+ if (empty($instanceId)) {
return $pathToRewrite;
}
@@ -356,7 +364,7 @@ class SettingsPiwik
throw new Exception("The path $pathToRewrite was expected to contain the string $leadingPathToAppendHostnameTo");
}
- $tmpToReplace = $leadingPathToAppendHostnameTo . $hostname . '/';
+ $tmpToReplace = $leadingPathToAppendHostnameTo . $instanceId . '/';
// replace only the latest occurrence (in case path contains twice /tmp)
$pathToRewrite = substr_replace($pathToRewrite, $tmpToReplace, $posTmp, strlen($leadingPathToAppendHostnameTo));
@@ -364,16 +372,31 @@ class SettingsPiwik
}
/**
- * @return bool|string
+ * @throws \Exception
+ * @return string or False if not set
*/
- protected static function getConfigHostname()
+ protected static function getPiwikInstanceId()
{
+ // until Piwik is installed, we use hostname as instance_id
if(!self::isPiwikInstalled()
&& Common::isPhpCliMode()) {
// enterprise:install use case
return Config::getHostname();
}
- return Config::getInstance()->getConfigHostnameIfSet();
+
+ $instanceId = @Config::getInstance()->General['instance_id'];
+ if(!empty($instanceId)) {
+ return $instanceId;
+ }
+
+ // Backward compatbility, in case the instance_id is not in the config file yet
+ $configHostname = Config::getInstance()->getConfigHostnameIfSet();
+ if(!empty($configHostname)) {
+ return $configHostname;
+ }
+
+ // do not rewrite the path as Piwik uses the standard config.ini.php file
+ return false;
}
/**
diff --git a/core/Twig.php b/core/Twig.php
index 6b628c9be7..8c5ce8a2ef 100755
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -60,7 +60,7 @@ class Twig
// Create new Twig Environment and set cache dir
$templatesCompiledPath = PIWIK_USER_PATH . '/tmp/templates_c';
- $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithHostname($templatesCompiledPath);
+ $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithInstanceId($templatesCompiledPath);
$this->twig = new Twig_Environment($chainLoader,
array(
diff --git a/core/Url.php b/core/Url.php
index 7d5d05d08d..fbcd379df5 100644
--- a/core/Url.php
+++ b/core/Url.php
@@ -557,12 +557,7 @@ class Url
public static function getTrustedHosts()
{
- $trustedHosts = self::getTrustedHostsFromConfig();
-
- /* used by Piwik PRO */
- Piwik::postEvent('Url.filterTrustedHosts', array(&$trustedHosts));
-
- return $trustedHosts;
+ return self::getTrustedHostsFromConfig();
}
/**