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 /plugins
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.
Diffstat (limited to 'plugins')
-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
7 files changed, 42 insertions, 38 deletions
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);