diff options
26 files changed, 127 insertions, 98 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ae12c73545..c336a07228 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 9a25907242..7dc6daa18f 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 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 26befbc8ef..8a1bffd773 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 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 0c37680fc4..d673ccc250 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 159c518cc9..125c47bfda 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 553f6b393f..7d1702315f 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 41fbf851b1..1315362c38 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 5a9d0ac68f..cb68432725 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 edd468c95e..9e49987072 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 23780a0701..1291c7fe13 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 948185876b..1127d47a60 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 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 84b254e86e..e95f7f1d74 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 21968924ed..55c223cbb8 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 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 386b348fda..e3950fea65 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 ff6884e62b..2150dc32ba 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); |