diff --git a/CHANGELOG.md b/CHANGELOG.md index ae12c735453f2896749cb44150fcbc7a1bcb7c12..c336a072286f4c36472c05bd537ab49407ee09c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,14 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API' ### New commands * `core:plugin list` lists all plugins currently activated in Piwik. +## 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 9a2590724204fa139b520cf3db57b1dab98efcab..7dc6daa18fb84369d196c05d4497c50df4b2b234 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 plugins 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 6759facb2b573f1ed0c66210d7cb1d7f24ba488e..8c7d2adfa7fa7a2dea02deab2022cdf051244ab7 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 48a23004bf3521a93264f7c2ca6883ac8f3ad41d..b8ec14c57560d78122a76889a422da4717cd02d5 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 26befbc8ef10eeab44df38a70e97d2c61ff09cd1..8a1bffd773be9f47916a0f84140f75c083e62e72 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. @@ -228,8 +229,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 f6e7a223c78c9f5d001a096a35db250871715a77..bb620d692e48211edd11ff25ca6525a1a5f93c9f 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 0c37680fc4dc6e10dfee33e22d184fc26746bde8..d673ccc2502fa4e784daf409ebf158958c8c9ae3 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 159c518cc900ee5fb3cf972a076708d1ba1620c5..125c47bfda7192799a2c6dcdbf03713604a32c94 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; /** @@ -413,7 +414,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 553f6b393fa5e312f9060afbd800abb3e0ca0de6..7d1702315ff577b6ae246440d685d456288e9a5e 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -311,21 +311,23 @@ class FrontController extends Singleton Registry::set('timer', new Timer); + $exceptionToThrow = self::createConfigObject(); + + $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(); Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck); - $exceptionToThrow = self::createConfigObject(); - $this->handleMaintenanceMode(); $this->handleProfiler(); $this->handleSSLRedirection(); diff --git a/core/Log.php b/core/Log.php index 41fbf851b162d83de691713b81ff6ca08967f16d..1315362c384eeb4658cc52c124b9b513773e4344 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,23 @@ class Log extends Singleton private function setLogFilePathFromConfig($logConfig) { $logPath = @$logConfig[self::LOGGER_FILE_PATH_CONFIG_OPTION]; + + // Absolute path + if (strpos($logPath, '/') === 0) { + $this->logToFilePath = $logPath; + return; + } + + // 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 +339,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 5a9d0ac68f1eb38e6082fbbff25f09655fb8ed47..cb6843272534cf373a1cb47a3f9b65d590a984b6 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 0d634c4928c6ae08d776358baeb687f46c8aa8e8..5486d5cd21821928186a69095c318e2b84619cef 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 edd468c95e319ccbaca9cc04399deb11cede1ea8..9e49987072b012626a8b1aacbda2cfd632cb16f5 100644 --- a/core/Session.php +++ b/core/Session.php @@ -9,6 +9,7 @@ namespace Piwik; use Exception; +use Piwik\Container\StaticContainer; use Piwik\Exception\MissingFilePermissionException; use Piwik\Session\SaveHandler\DbTable; use Zend_Session; diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 23780a0701566ec100b3593724147a4e15b31991..1291c7fe13750ee4dec75e641370c5d2f8f85276 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. @@ -256,19 +257,13 @@ class SettingsPiwik return $result; } - /** - * @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 c43beca189934bcfd6db7c58044811440fe48b54..9ace61b74b6789090d1eb794df16e61b6bcaeb5e 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 948185876bd41e2bcc322885498c096f694b22a4..1127d47a606595820df312ce3ba64c14651e0f38 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\Metrics\Formatter; use Piwik\Translate; @@ -64,8 +65,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 4638f8bd27b3f35dff8acdbcedd7b1e13b4e9388..37513b1a42d24780c369a6be97e0238757124f5c 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 f6dd3bba5f3e5d77a013ec60e8af164f185484cc..d2b650726c83430c78c0b175ce50e08939fd3bb9 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 84b254e86e26789d7930ce820990d002abef65b0..e95f7f1d74a774d510339391bb3d4dd6effa2012 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 5dbc14b56598f684119cb38dc22197f610290fb0..bbb0cdc7f241b77b6e016fb900c97889c20ccf2c 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 d9aeeabe677d7925db7cdb155953296d949c3342..f9bb63c6bf4037ac83a324ae8a33eaa5551469c2 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 21968924ed2c5e4043bb3493160a107d1feb48e4..55c223cbb83fd40fe891e4acfce37f18f4ceca6e 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; @@ -145,16 +146,18 @@ class SystemCheck */ protected static function getDirectoriesShouldBeWritable() { + $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 b1149a9afe78969c7c8a948faa5f04dc9b1aa566..a28f62df232b16c4bb652f9048d0c400e56f3c3e 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 8b8e0e98dabcba509eeec63606be823b110be327..f7a92b00065333291de654d29c2870167710df6f 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 386b348fda21a051bab2c44f5003a76dd3c803a7..e3950fea654e9cfff8f84c307cd1fdac878f1d5d 100644 --- a/tests/PHPUnit/Integration/LogTest.php +++ b/tests/PHPUnit/Integration/LogTest.php @@ -11,6 +11,7 @@ namespace Piwik\Tests\Integration; use Exception; use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\Db; use Piwik\Error; use Piwik\ExceptionHandler; @@ -34,9 +35,9 @@ class LogTest extends IntegrationTestCase 'screen' => 'dummy error message<br /> <br /> --> To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php', - 'file' => '[Piwik\Tests\Integration\LogTest] LogTest.php(160): dummy error message + 'file' => '[Piwik\Tests\Integration\LogTest] LogTest.php(162): dummy error message dummy backtrace', - 'database' => '[Piwik\Tests\Integration\LogTest] LogTest.php(160): dummy error message + 'database' => '[Piwik\Tests\Integration\LogTest] LogTest.php(162): dummy error message dummy backtrace' ); @@ -77,7 +78,8 @@ dummy backtrace' parent::setUp(); Config::getInstance()->log['string_message_format'] = self::STRING_MESSAGE_FORMAT; - Config::getInstance()->log['logger_file_path'] = self::getDefaultLogFileLocation(); + Config::getInstance()->log['logger_file_path'] = self::getLogFileLocation(); + Config::getInstance()->log['log_level'] = Log::INFO; @unlink(self::getLogFileLocation()); Log::unsetInstance(); Error::$debugBacktraceForTests = ExceptionHandler::$debugBacktraceForTests = "dummy backtrace"; @@ -279,14 +281,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 ff6884e62b0a856156e78075b5083ea06eb8f2aa..2150dc32bac303ae19276ef19674079eb88f6891 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); $validTill = '2015-05-01'; $this->assertDeprecatedMethodIsRemoved('Piwik\Plugins\UserSettings\API', 'getBrowserVersion', $validTill);