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

Moved the tmp/ path into the config (was hardcoded everywhere) #6658

Merged
merged 11 commits into from Dec 2, 2014
Merged

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Nov 13, 2014

This PR is based on #6648

The tmp/ path was hardcoded everywhere, which resulted in using SettingsPiwik::rewriteTmpPathWithInstanceId() to rewrite it for specific use cases. This is risky as developers have to remind to call this "rewrite" method everytime (and in some place it wasn't…), and it makes everything not really customizable (rewriteTmpPathWithInstanceId() had to be added so that for "multiple piwik instances scenarios" we could customize the path with an "instance ID"…).

I've moved the tmp/ 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 might 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 be assured that it will be taken into account everywhere in Piwik.

@mnapoli mnapoli added the c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. label Nov 13, 2014
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.
@mattab
Copy link
Member

mattab commented Nov 28, 2014

Hi @mnapoli if this is for 2.10.0 could you set the milestone? cheers

@mnapoli mnapoli added this to the Piwik 2.10.0 milestone Nov 28, 2014
@mnapoli
Copy link
Contributor Author

mnapoli commented Nov 28, 2014

Done. Ready to be merged.

@@ -132,10 +133,7 @@ public static function start($options = false)
$e->getMessage()
);

$ex = new MissingFilePermissionException($message, $e->getCode(), $e);
$ex->setIsHtmlMessage();
Copy link
Member

Choose a reason for hiding this comment

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

is this change expected in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, fixed. Waiting for the tests to pass before merging.

@mnapoli
Copy link
Contributor Author

mnapoli commented Nov 30, 2014

Do not merge yet ;)

@mnapoli
Copy link
Contributor Author

mnapoli commented Nov 30, 2014

All good, @mattab please review 4a2145a#diff-842c76803d19071217437497af04afd5R327 it was necessary to check for the config file before testing for the permissions on the directories. The reason is that the directories are now resolved by getting the tmp path from the config…

mattab pushed a commit that referenced this pull request Dec 2, 2014
Moved the `tmp/` path into the config (was hardcoded everywhere)
@mattab mattab merged commit a0d3bf9 into master Dec 2, 2014
@mnapoli mnapoli deleted the tmp-path branch December 2, 2014 00:37
@mnapoli mnapoli self-assigned this Dec 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants