diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-11-13 05:15:51 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-11-13 05:30:34 +0300 |
commit | c9d698f4fb8f9ed683bc737b7991edb3793fa498 (patch) | |
tree | fbacb0525496ea3505f144c876f65338e80ce1bc /plugins/CorePluginsAdmin/PluginInstaller.php | |
parent | c831518f45f2e75dce59639e7a2a10a90a830c91 (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/CorePluginsAdmin/PluginInstaller.php')
-rw-r--r-- | plugins/CorePluginsAdmin/PluginInstaller.php | 19 |
1 files changed, 10 insertions, 9 deletions
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) |