Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy downloaded plugin to all plugins directories #14537

Merged
merged 5 commits into from Jul 5, 2019

Conversation

nabiltntn
Copy link
Contributor

@nabiltntn nabiltntn commented Jun 18, 2019

When downloading a plugins from Marketplace UI, it would be useful to copy them also to folders defined in MATOMO_PLUGINS_DIRS . This is useful when Matomo is deployed in env with Persistent Volume like Kubernetes

The PR copies plugin to all directories and not to one of them because in practice MATOMO_PLUGINS_DIRS will have only one directory outside Matomo directory.

fixes #14534

@@ -705,6 +705,9 @@
; breaks and reencrypts SSL connections you can set your custom file here.
custom_cacert_pem=

; set to 1 to copy downloaded plugins to all plugins directories including those defined in MATOMO_PLUGIN_DIRS env variable
copy_to_plugins_dirs = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nabiltntn AFAIK MATOMO_PLUGIN_DIRS is either defined as an environment variable or GLOBALS (through bootstrap.php). Should we have the same for this directory that it can be only configured as a GLOBAL and/or ENV variable? Because the feature should only work if the copy to plugin directory is also defined as a plugin directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the implementation to use a new env var : MATOMO_PLUGIN_COPY_DIR

if (!empty(Config::getInstance()->General['copy_to_plugins_dirs'])) {
$pluginsDirs = Manager::getPluginsDirectories();
// Copy plugin to all plugins directories
foreach ($pluginsDirs as $dir) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copies it into all plugin directories, I reckon matomo may have trouble with this if there are multiple directories defined. It should copy the plugin only into one plugin directory. We have uses cases where we define multiple plugin directories (one directory for each plugin in fact)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed to copy only to directory defined in MATOMO_PLUGIN_COPY_DIR if it's within getPluginsDirectories array


$pluginsDirs = [Manager::getPluginsDirectory()];

if (!empty($GLOBALS['MATOMO_PLUGIN_COPY_DIR'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case someone configures $GLOBALS['MATOMO_PLUGIN_COPY_DIR'] directly, do we maybe also need to check that directory is actually one of the configured plugin directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i made a change in initPluginDirectories to check $GLOBALS['MATOMO_PLUGIN_COPY_DIR'] in both cases ( via env var or directly )

@mattab mattab added this to the 3.11.0 milestone Jun 27, 2019
@mattab mattab added the Needs Review PRs that need a code review label Jun 27, 2019
@tsteur
Copy link
Member

tsteur commented Jul 5, 2019

cheers @nabiltntn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy downloaded plugins from Marketplace to MATOMO_PLUGIN_DIRS folder too
3 participants