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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-11-13 05:15:51 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-11-13 05:30:34 +0300
commitc9d698f4fb8f9ed683bc737b7991edb3793fa498 (patch)
treefbacb0525496ea3505f144c876f65338e80ce1bc
parentc831518f45f2e75dce59639e7a2a10a90a830c91 (diff)
Moved the `tmp/` path into the config (was hardcoded everywhere)
The `tmp/` path was hardcoded everywhere, which resulted in using `SettingsPiwik::rewriteTmpPathWithInstanceId()` to rewrite it for specific use cases. I've moved that path into the config, and replaced all hardcoded usage (and calls to `rewriteTmpPathWithInstanceId()`) by a `get()` from the container. Getting entries from the container is a bad practice and dependency injection should be preferred, but we do baby steps. When refactoring those classes to DI, we'll replace calls to the container with proper dependency injection. Another thing we'll need to do too is move the hardcoded *sub-path* of `tmp/` (e.g. `tmp/sessions/`) into the config also (but again: baby steps). Another future step would be to remove completely instance ID and let it be handled by a plugin (or by end-user config). Having the `tmp/` path in the config means that plugins or users can override it and know it will be taken into account everywhere in Piwik.
-rw-r--r--CHANGELOG.md8
-rw-r--r--config/global.php19
-rw-r--r--core/AssetManager.php4
-rw-r--r--core/CacheFile.php4
-rw-r--r--core/CliMulti.php4
-rw-r--r--core/Db/BatchInsert.php5
-rw-r--r--core/Filechecks.php4
-rw-r--r--core/Filesystem.php3
-rw-r--r--core/FrontController.php14
-rw-r--r--core/Log.php15
-rw-r--r--core/Profiler.php3
-rw-r--r--core/ReportRenderer.php4
-rw-r--r--core/Session.php8
-rw-r--r--core/SettingsPiwik.php11
-rw-r--r--core/Translate/Writer.php3
-rwxr-xr-xcore/Twig.php4
-rw-r--r--misc/cron/updatetoken.php6
-rw-r--r--plugins/CoreConsole/Commands/WatchLog.php5
-rw-r--r--plugins/CorePluginsAdmin/PluginInstaller.php19
-rw-r--r--plugins/CoreUpdater/Controller.php13
-rw-r--r--plugins/ImageGraph/StaticGraph.php5
-rw-r--r--plugins/Installation/SystemCheck.php21
-rw-r--r--plugins/LanguagesManager/Commands/FetchFromOTrance.php13
-rw-r--r--plugins/ScheduledReports/config/tcpdf_config.php4
-rw-r--r--tests/PHPUnit/Integration/LogTest.php12
-rw-r--r--tests/PHPUnit/Unit/DeprecatedMethodsTest.php2
26 files changed, 116 insertions, 97 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03ea44224a..b8c4bb17b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,14 @@
This is a changelog for Piwik platform developers. All changes for our HTTP API's, Plugins, Themes, etc will be listed here.
+## Piwik 2.10.0
+
+### Breaking Changes
+* The deprecated method `Piwik\SettingsPiwik::rewriteTmpPathWithHostname()` has been removed.
+
+### Deprecations
+* `Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId()` has been deprecated. Instead of hardcoding the `tmp/` path everywhere in the codebase and then calling `rewriteTmpPathWithInstanceId()`, developers should get the `path.tmp` configuration value from the DI container (e.g. `StaticContainer::getContainer()->get('path.tmp')`).
+
## Piwik 2.9.0
### Breaking Changes
diff --git a/config/global.php b/config/global.php
index 9a25907242..cb3bf82996 100644
--- a/config/global.php
+++ b/config/global.php
@@ -1,4 +1,23 @@
<?php
+use Interop\Container\ContainerInterface;
+
return array(
+
+ 'path.root' => PIWIK_USER_PATH,
+
+ 'path.tmp' => DI\factory(function (ContainerInterface $c) {
+ $root = $c->get('path.root');
+
+ // TODO remove that special case and instead have CloudAdmin plugin override 'path.tmp' to add the instance id
+ if ($c->has('old_config.General.instance_id')) {
+ $instanceId = $c->get('old_config.General.instance_id');
+ $instanceId = $instanceId ? '/' . $instanceId : '';
+ } else {
+ $instanceId = '';
+ }
+
+ return $root . '/tmp' . $instanceId;
+ }),
+
);
diff --git a/core/AssetManager.php b/core/AssetManager.php
index 6759facb2b..8c7d2adfa7 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -20,6 +20,7 @@ use Piwik\AssetManager\UIAssetFetcher;
use Piwik\AssetManager\UIAssetMerger\JScriptUIAssetMerger;
use Piwik\AssetManager\UIAssetMerger\StylesheetUIAssetMerger;
use Piwik\Config as PiwikConfig;
+use Piwik\Container\StaticContainer;
use Piwik\Plugin\Manager;
use Piwik\Translate;
@@ -252,8 +253,7 @@ class AssetManager extends Singleton
*/
public function getAssetDirectory()
{
- $mergedFileDirectory = PIWIK_USER_PATH . "/tmp/assets";
- $mergedFileDirectory = SettingsPiwik::rewriteTmpPathWithInstanceId($mergedFileDirectory);
+ $mergedFileDirectory = StaticContainer::getContainer()->get('path.tmp') . '/assets';
if (!is_dir($mergedFileDirectory)) {
Filesystem::mkdir($mergedFileDirectory);
diff --git a/core/CacheFile.php b/core/CacheFile.php
index 48a23004bf..b8ec14c575 100644
--- a/core/CacheFile.php
+++ b/core/CacheFile.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
/**
* This class is used to cache data on the filesystem.
@@ -43,8 +44,7 @@ class CacheFile
*/
public function __construct($directory, $timeToLiveInSeconds = 300)
{
- $cachePath = PIWIK_USER_PATH . '/tmp/cache/' . $directory . '/';
- $this->cachePath = SettingsPiwik::rewriteTmpPathWithInstanceId($cachePath);
+ $this->cachePath = StaticContainer::getContainer()->get('path.tmp') . '/cache/' . $directory . '/';
if ($timeToLiveInSeconds < self::MINIMUM_TTL) {
$timeToLiveInSeconds = self::MINIMUM_TTL;
diff --git a/core/CliMulti.php b/core/CliMulti.php
index 992a4e1dd4..aee8d7e35d 100644
--- a/core/CliMulti.php
+++ b/core/CliMulti.php
@@ -10,6 +10,7 @@ namespace Piwik;
use Piwik\CliMulti\CliPhp;
use Piwik\CliMulti\Output;
use Piwik\CliMulti\Process;
+use Piwik\Container\StaticContainer;
/**
* Class CliMulti.
@@ -220,8 +221,7 @@ class CliMulti {
public static function getTmpPath()
{
- $dir = PIWIK_INCLUDE_PATH . '/tmp/climulti';
- return SettingsPiwik::rewriteTmpPathWithInstanceId($dir);
+ return StaticContainer::getContainer()->get('path.tmp') . '/climulti';
}
private function executeAsyncCli($url, Output $output, $cmdId)
diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php
index f6e7a223c7..bb620d692e 100644
--- a/core/Db/BatchInsert.php
+++ b/core/Db/BatchInsert.php
@@ -12,10 +12,10 @@ use Exception;
use Piwik\AssetManager;
use Piwik\Common;
use Piwik\Config;
+use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\DbHelper;
use Piwik\Log;
-use Piwik\SettingsPiwik;
use Piwik\SettingsServer;
class BatchInsert
@@ -57,8 +57,7 @@ class BatchInsert
*/
public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
{
- $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
- $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
+ $filePath = StaticContainer::getContainer()->get('path.tmp') . '/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
$loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
diff --git a/core/Filechecks.php b/core/Filechecks.php
index eab93fd260..dab57f43f2 100644
--- a/core/Filechecks.php
+++ b/core/Filechecks.php
@@ -45,10 +45,6 @@ class Filechecks
$directoryToCheck = PIWIK_USER_PATH . $directoryToCheck;
}
- if (strpos($directoryToCheck, '/tmp/') !== false) {
- $directoryToCheck = SettingsPiwik::rewriteTmpPathWithInstanceId($directoryToCheck);
- }
-
Filesystem::mkdir($directoryToCheck);
$directory = Filesystem::realpath($directoryToCheck);
diff --git a/core/Filesystem.php b/core/Filesystem.php
index 8f34c6a1c8..ffeef1f3be 100644
--- a/core/Filesystem.php
+++ b/core/Filesystem.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
use Piwik\Tracker\Cache;
/**
@@ -379,7 +380,7 @@ class Filesystem
*/
private static function getChmodForPath($path)
{
- $pathIsTmp = self::getPathToPiwikRoot() . '/tmp';
+ $pathIsTmp = StaticContainer::getContainer()->get('path.tmp');
if (strpos($path, $pathIsTmp) === 0) {
// tmp/* folder
return 0750;
diff --git a/core/FrontController.php b/core/FrontController.php
index f49fa94655..121d7c0e26 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -311,13 +311,15 @@ class FrontController extends Singleton
Registry::set('timer', new Timer);
+ $tmpPath = StaticContainer::getContainer()->get('path.tmp');
+
$directoriesToCheck = array(
- '/tmp/',
- '/tmp/assets/',
- '/tmp/cache/',
- '/tmp/logs/',
- '/tmp/tcpdf/',
- '/tmp/templates_c/',
+ $tmpPath,
+ $tmpPath . '/assets/',
+ $tmpPath . '/cache/',
+ $tmpPath . '/logs/',
+ $tmpPath . '/tcpdf/',
+ $tmpPath . '/templates_c/',
);
Translate::loadEnglishTranslation();
diff --git a/core/Log.php b/core/Log.php
index 41fbf851b1..ab6c6070e9 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -8,6 +8,7 @@
*/
namespace Piwik;
+use Piwik\Container\StaticContainer;
use Piwik\Db;
/**
@@ -313,16 +314,16 @@ class Log extends Singleton
private function setLogFilePathFromConfig($logConfig)
{
$logPath = @$logConfig[self::LOGGER_FILE_PATH_CONFIG_OPTION];
+ // Remove 'tmp/' at the beginning
+ if (strpos($logPath, 'tmp/') === 0) {
+ $logPath = substr($logPath, strlen('tmp'));
+ }
+
if (empty($logPath)) {
$logPath = $this->getDefaultFileLogPath();
}
- if (!SettingsServer::isWindows()
- && $logPath[0] != '/'
- ) {
- $logPath = PIWIK_USER_PATH . DIRECTORY_SEPARATOR . $logPath;
- }
- $logPath = SettingsPiwik::rewriteTmpPathWithInstanceId($logPath);
+ $logPath = StaticContainer::getContainer()->get('path.tmp') . $logPath;
if (is_dir($logPath)) {
$logPath .= '/piwik.log';
}
@@ -331,7 +332,7 @@ class Log extends Singleton
private function getDefaultFileLogPath()
{
- return 'tmp/logs/piwik.log';
+ return '/logs/piwik.log';
}
private function getAvailableWriters()
diff --git a/core/Profiler.php b/core/Profiler.php
index 2b92583d89..45af8df6fa 100644
--- a/core/Profiler.php
+++ b/core/Profiler.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
use XHProfRuns_Default;
/**
@@ -337,6 +338,6 @@ class Profiler
*/
private static function getPathToXHProfRunIds()
{
- return PIWIK_INCLUDE_PATH . '/tmp/cache/tests-xhprof-runs';
+ return StaticContainer::getContainer()->get('path.tmp') . '/cache/tests-xhprof-runs';
}
}
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index 0d634c4928..5486d5cd21 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -10,6 +10,7 @@ namespace Piwik;
use Exception;
use Piwik\API\Request;
+use Piwik\Container\StaticContainer;
use Piwik\DataTable\Row;
use Piwik\DataTable\Simple;
use Piwik\DataTable;
@@ -144,8 +145,7 @@ abstract class ReportRenderer extends BaseFactory
*/
protected static function getOutputPath($filename)
{
- $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
- $outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
+ $outputFilename = StaticContainer::getContainer()->get('path.tmp') . '/assets/' . $filename;
@chmod($outputFilename, 0600);
@unlink($outputFilename);
diff --git a/core/Session.php b/core/Session.php
index d8fa47b4d2..38442f4d65 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
use Piwik\Exceptions\HtmlMessageException;
use Piwik\Session\SaveHandler\DbTable;
use Zend_Session;
@@ -123,8 +124,8 @@ class Session extends Zend_Session
we recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' target='_blank'>enable database session storage</a>.";
}
- $pathToSessions = Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/');
- $pathToSessions = SettingsPiwik::rewriteTmpPathWithInstanceId($pathToSessions);
+ $pathToSessions = StaticContainer::getContainer()->get('path.tmp') . '/sessions/';
+ $pathToSessions = Filechecks::getErrorMessageMissingPermissions($pathToSessions);
$message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>",
Piwik::translate('General_ExceptionUnableToStartSession'),
$pathToSessions,
@@ -143,8 +144,7 @@ class Session extends Zend_Session
*/
public static function getSessionsDirectory()
{
- $path = PIWIK_USER_PATH . '/tmp/sessions';
- return SettingsPiwik::rewriteTmpPathWithInstanceId($path);
+ return StaticContainer::getContainer()->get('path.tmp') . '/sessions';
}
public static function close()
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index 26949c560a..1d972a7f88 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
/**
* Contains helper methods that can be used to get common Piwik settings.
@@ -257,18 +258,12 @@ 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
+ *
+ * @deprecated Get the 'path.tmp' config from the container instead.
*/
public static function rewriteTmpPathWithInstanceId($path)
{
diff --git a/core/Translate/Writer.php b/core/Translate/Writer.php
index c43beca189..9ace61b74b 100644
--- a/core/Translate/Writer.php
+++ b/core/Translate/Writer.php
@@ -10,6 +10,7 @@
namespace Piwik\Translate;
use Exception;
+use Piwik\Container\StaticContainer;
use Piwik\Filesystem;
use Piwik\Piwik;
use Piwik\Translate\Filter\FilterAbstract;
@@ -200,7 +201,7 @@ class Writer
if (!empty($this->pluginName)) {
if ($base == 'tmp') {
- return sprintf('%s/tmp/plugins/%s/lang/%s.json', PIWIK_INCLUDE_PATH, $this->pluginName, $lang);
+ return sprintf('%s/plugins/%s/lang/%s.json', StaticContainer::getContainer()->get('path.tmp'), $this->pluginName, $lang);
} else {
return sprintf('%s/plugins/%s/lang/%s.json', PIWIK_INCLUDE_PATH, $this->pluginName, $lang);
}
diff --git a/core/Twig.php b/core/Twig.php
index 2e0ef95844..bf840950a5 100755
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -9,6 +9,7 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
use Piwik\DataTable\Filter\SafeDecodeLabel;
use Piwik\Period\Range;
use Piwik\Translate;
@@ -60,8 +61,7 @@ class Twig
$chainLoader = new Twig_Loader_Chain($loaders);
// Create new Twig Environment and set cache dir
- $templatesCompiledPath = PIWIK_USER_PATH . '/tmp/templates_c';
- $templatesCompiledPath = SettingsPiwik::rewriteTmpPathWithInstanceId($templatesCompiledPath);
+ $templatesCompiledPath = StaticContainer::getContainer()->get('path.tmp') . '/templates_c';
$this->twig = new Twig_Environment($chainLoader,
array(
diff --git a/misc/cron/updatetoken.php b/misc/cron/updatetoken.php
index 4638f8bd27..37513b1a42 100644
--- a/misc/cron/updatetoken.php
+++ b/misc/cron/updatetoken.php
@@ -11,6 +11,8 @@
namespace Piwik;
+use Piwik\Container\StaticContainer;
+
if (!defined('PIWIK_INCLUDE_PATH')) {
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
}
@@ -57,9 +59,7 @@ $token = Db::get()->fetchOne("SELECT token_auth
WHERE superuser_access = 1
ORDER BY date_registered ASC");
-$filename = PIWIK_INCLUDE_PATH . '/tmp/cache/token.php';
-
-$filename = SettingsPiwik::rewriteTmpPathWithInstanceId($filename);
+$filename = StaticContainer::getContainer()->get('path.tmp') . '/cache/token.php';
$content = "<?php exit; //\t" . $token;
file_put_contents($filename, $content);
diff --git a/plugins/CoreConsole/Commands/WatchLog.php b/plugins/CoreConsole/Commands/WatchLog.php
index f6dd3bba5f..d2b650726c 100644
--- a/plugins/CoreConsole/Commands/WatchLog.php
+++ b/plugins/CoreConsole/Commands/WatchLog.php
@@ -9,8 +9,8 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Container\StaticContainer;
use Piwik\Plugin\ConsoleCommand;
-use Piwik\SettingsPiwik;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -26,8 +26,7 @@ class WatchLog extends ConsoleCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
- $path = sprintf('%s/tmp/logs/', PIWIK_DOCUMENT_ROOT);
- $path = SettingsPiwik::rewriteTmpPathWithInstanceId($path);
+ $path = StaticContainer::getContainer()->get('path.tmp') . '/logs/';
$cmd = sprintf('tail -f %s*.log', $path);
$output->writeln('Executing command: ' . $cmd);
diff --git a/plugins/CorePluginsAdmin/PluginInstaller.php b/plugins/CorePluginsAdmin/PluginInstaller.php
index 8bb9c475d0..d848e5c427 100644
--- a/plugins/CorePluginsAdmin/PluginInstaller.php
+++ b/plugins/CorePluginsAdmin/PluginInstaller.php
@@ -8,11 +8,11 @@
*/
namespace Piwik\Plugins\CorePluginsAdmin;
+use Piwik\Container\StaticContainer;
use Piwik\Filechecks;
use Piwik\Filesystem;
use Piwik\Piwik;
use Piwik\Plugin\Dependency as PluginDependency;
-use Piwik\SettingsPiwik;
use Piwik\Unzip;
/**
@@ -20,7 +20,7 @@ use Piwik\Unzip;
*/
class PluginInstaller
{
- const PATH_TO_DOWNLOAD = '/tmp/latest/plugins/';
+ const PATH_TO_DOWNLOAD = '/latest/plugins/';
const PATH_TO_EXTRACT = '/plugins/';
private $pluginName;
@@ -32,11 +32,10 @@ class PluginInstaller
public function installOrUpdatePluginFromMarketplace()
{
- $tmpPluginZip = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName . '.zip';
- $tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
+ $tmpPluginPath = StaticContainer::getContainer()->get('path.tmp') . '/latest/plugins/';
- $tmpPluginZip = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginZip);
- $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginFolder);
+ $tmpPluginZip = $tmpPluginPath . $this->pluginName . '.zip';
+ $tmpPluginFolder = $tmpPluginPath . $this->pluginName;
try {
$this->makeSureFoldersAreWritable();
@@ -64,8 +63,7 @@ class PluginInstaller
public function installOrUpdatePluginFromFile($pathToZip)
{
- $tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
- $tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithInstanceId($tmpPluginFolder);
+ $tmpPluginFolder = StaticContainer::getContainer()->get('path.tmp') . self::PATH_TO_DOWNLOAD . $this->pluginName;
try {
$this->makeSureFoldersAreWritable();
@@ -98,7 +96,10 @@ class PluginInstaller
private function makeSureFoldersAreWritable()
{
- Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_DOWNLOAD, self::PATH_TO_EXTRACT));
+ Filechecks::dieIfDirectoriesNotWritable(array(
+ StaticContainer::getContainer()->get('path.tmp') . self::PATH_TO_DOWNLOAD,
+ self::PATH_TO_EXTRACT
+ ));
}
private function downloadPluginFromMarketplace($pluginZipTargetFile)
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index 5dbc14b565..bbb0cdc7f2 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -12,6 +12,7 @@ use Exception;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Common;
use Piwik\Config;
+use Piwik\Container\StaticContainer;
use Piwik\DbHelper;
use Piwik\Filechecks;
use Piwik\Filesystem;
@@ -22,7 +23,6 @@ use Piwik\Plugin\Manager as PluginManager;
use Piwik\Plugin;
use Piwik\Plugins\CorePluginsAdmin\Marketplace;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
-use Piwik\SettingsPiwik;
use Piwik\SettingsServer;
use Piwik\Unzip;
use Piwik\UpdateCheck;
@@ -36,7 +36,7 @@ use Piwik\View;
*/
class Controller extends \Piwik\Plugin\Controller
{
- const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest/';
+ const PATH_TO_EXTRACT_LATEST_VERSION = '/latest/';
private $coreError = false;
private $warningMessages = array();
@@ -164,10 +164,10 @@ class Controller extends \Piwik\Plugin\Controller
private function oneClick_Download()
{
- $pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip';
- $this->pathPiwikZip = SettingsPiwik::rewriteTmpPathWithInstanceId($pathPiwikZip);
+ $path = StaticContainer::getContainer()->get('path.tmp') . self::PATH_TO_EXTRACT_LATEST_VERSION;
+ $this->pathPiwikZip = $path . 'latest.zip';
- Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_EXTRACT_LATEST_VERSION));
+ Filechecks::dieIfDirectoriesNotWritable(array($path));
// we catch exceptions in the caller (i.e., oneClickUpdate)
$url = self::getLatestZipUrl($this->newVersion) . '?cb=' . $this->newVersion;
@@ -177,8 +177,7 @@ class Controller extends \Piwik\Plugin\Controller
private function oneClick_Unpack()
{
- $pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION;
- $pathExtracted = SettingsPiwik::rewriteTmpPathWithInstanceId($pathExtracted);
+ $pathExtracted = StaticContainer::getContainer()->get('path.tmp') . self::PATH_TO_EXTRACT_LATEST_VERSION;
$this->pathRootExtractedPiwik = $pathExtracted . 'piwik';
diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php
index d9aeeabe67..f9bb63c6bf 100644
--- a/plugins/ImageGraph/StaticGraph.php
+++ b/plugins/ImageGraph/StaticGraph.php
@@ -12,8 +12,8 @@ namespace Piwik\Plugins\ImageGraph;
use Exception;
use pData;
use pImage;
+use Piwik\Container\StaticContainer;
use Piwik\Piwik;
-use Piwik\SettingsPiwik;
use Piwik\BaseFactory;
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pDraw.class.php";
@@ -229,8 +229,7 @@ abstract class StaticGraph extends BaseFactory
*/
protected static function getOutputPath($filename)
{
- $outputFilename = PIWIK_USER_PATH . '/tmp/assets/' . $filename;
- $outputFilename = SettingsPiwik::rewriteTmpPathWithInstanceId($outputFilename);
+ $outputFilename = StaticContainer::getContainer()->get('path.tmp') . '/assets/' . $filename;
@chmod($outputFilename, 0600);
@unlink($outputFilename);
diff --git a/plugins/Installation/SystemCheck.php b/plugins/Installation/SystemCheck.php
index b175528310..cd152f5efc 100644
--- a/plugins/Installation/SystemCheck.php
+++ b/plugins/Installation/SystemCheck.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\Installation;
use Piwik\CliMulti;
use Piwik\Common;
use Piwik\Config;
+use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\Db\Adapter;
use Piwik\DbHelper;
@@ -34,16 +35,18 @@ class SystemCheck
$infos = array();
+ $tmpPath = StaticContainer::getContainer()->get('path.tmp');
+
$directoriesToCheck = array(
- '/tmp/',
- '/tmp/assets/',
- '/tmp/cache/',
- '/tmp/climulti/',
- '/tmp/latest/',
- '/tmp/logs/',
- '/tmp/sessions/',
- '/tmp/tcpdf/',
- '/tmp/templates_c/',
+ $tmpPath,
+ $tmpPath . '/assets/',
+ $tmpPath . '/cache/',
+ $tmpPath . '/climulti/',
+ $tmpPath . '/latest/',
+ $tmpPath . '/logs/',
+ $tmpPath . '/sessions/',
+ $tmpPath . '/tcpdf/',
+ $tmpPath . '/templates_c/',
);
if (!DbHelper::isInstalled()) {
diff --git a/plugins/LanguagesManager/Commands/FetchFromOTrance.php b/plugins/LanguagesManager/Commands/FetchFromOTrance.php
index b1149a9afe..a28f62df23 100644
--- a/plugins/LanguagesManager/Commands/FetchFromOTrance.php
+++ b/plugins/LanguagesManager/Commands/FetchFromOTrance.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\LanguagesManager\Commands;
+use Piwik\Container\StaticContainer;
use Piwik\Unzip;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -18,12 +19,14 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class FetchFromOTrance extends TranslationBase
{
- const DOWNLOADPATH = 'tmp/oTrance';
+ const DOWNLOAD_PATH = '/oTrance';
protected function configure()
{
+ $path = StaticContainer::getContainer()->get('path.tmp') . self::DOWNLOAD_PATH;
+
$this->setName('translations:fetch')
- ->setDescription('Fetches translations files from oTrance to '.self::DOWNLOADPATH)
+ ->setDescription('Fetches translations files from oTrance to ' . $path)
->addOption('username', 'u', InputOption::VALUE_OPTIONAL, 'oTrance username')
->addOption('password', 'p', InputOption::VALUE_OPTIONAL, 'oTrance password')
->addOption('keep-english', 'k', InputOption::VALUE_NONE, 'keep english file');
@@ -162,9 +165,9 @@ class FetchFromOTrance extends TranslationBase
$output->writeln("Finished fetching new language files from oTrance");
}
- public static function getDownloadPath() {
-
- $path = PIWIK_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . self::DOWNLOADPATH;
+ public static function getDownloadPath()
+ {
+ $path = StaticContainer::getContainer()->get('path.tmp') . self::DOWNLOAD_PATH;
if (!is_dir($path)) {
mkdir($path);
diff --git a/plugins/ScheduledReports/config/tcpdf_config.php b/plugins/ScheduledReports/config/tcpdf_config.php
index 8b8e0e98da..f7a92b0006 100644
--- a/plugins/ScheduledReports/config/tcpdf_config.php
+++ b/plugins/ScheduledReports/config/tcpdf_config.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
+use Piwik\Container\StaticContainer;
/**
* Override settings in libs/tcpdf_config.php
@@ -14,8 +15,7 @@
define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/');
-$pathTmpTCPDF = PIWIK_USER_PATH . '/tmp/tcpdf/';
-$pathTmpTCPDF = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($pathTmpTCPDF);
+$pathTmpTCPDF = StaticContainer::getContainer()->get('path.tmp') . '/tcpdf/';
define('K_PATH_CACHE', $pathTmpTCPDF);
define('K_PATH_IMAGES', $pathTmpTCPDF);
diff --git a/tests/PHPUnit/Integration/LogTest.php b/tests/PHPUnit/Integration/LogTest.php
index 8934e31e85..b77eb10a15 100644
--- a/tests/PHPUnit/Integration/LogTest.php
+++ b/tests/PHPUnit/Integration/LogTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Common;
use Piwik\Config;
+use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\Error;
use Piwik\ExceptionHandler;
@@ -290,15 +291,6 @@ dummy backtrace'
public static function getLogFileLocation()
{
- $path = self::getDefaultLogFileLocation();
- $path = \Piwik\SettingsPiwik::rewriteTmpPathWithInstanceId($path);
- return $path;
+ return StaticContainer::getContainer()->get('path.tmp') . '/logs/piwik.test.log';
}
-
- protected static function getDefaultLogFileLocation()
- {
- $path = PIWIK_INCLUDE_PATH . '/tmp/logs/piwik.test.log';
- return $path;
- }
-
} \ No newline at end of file
diff --git a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
index 46dfca652f..64411e3f37 100644
--- a/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
+++ b/tests/PHPUnit/Unit/DeprecatedMethodsTest.php
@@ -29,7 +29,6 @@ class DeprecatedMethodsTest extends \PHPUnit_Framework_TestCase
$this->assertDeprecatedMethodIsRemoved('\Piwik\Menu\MenuAdmin', 'removeEntry', $validTill);
$this->assertDeprecatedMethodIsRemoved('\Piwik\Menu\MenuTop', 'addEntry', $validTill);
$this->assertDeprecatedMethodIsRemoved('\Piwik\Menu\MenuTop', 'removeEntry', $validTill);
- $this->assertDeprecatedMethodIsRemoved('\Piwik\SettingsPiwik', 'rewriteTmpPathWithHostname', $validTill);
$validTill = '2015-02-06';
$this->assertDeprecatedClassIsRemoved('\IntegrationTestCase', $validTill);
@@ -54,6 +53,7 @@ class DeprecatedMethodsTest extends \PHPUnit_Framework_TestCase
$this->assertDeprecatedMethodIsRemoved('Piwik\IP', 'getIpsForRange', $validTill);
$this->assertDeprecatedMethodIsRemoved('Piwik\IP', 'isIpInRange', $validTill);
$this->assertDeprecatedMethodIsRemoved('Piwik\IP', 'getHostByAddr', $validTill);
+ $this->assertDeprecatedMethodIsRemoved('Piwik\SettingsPiwik', 'rewriteTmpPathWithInstanceId', $validTill);
$this->assertDeprecatedMethodIsRemovedInPiwik3('\Piwik\Menu\MenuAbstract', 'add');
}