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

Fix user path was not working as it should (allow placing config file outside webroot) #14866

Merged
merged 2 commits into from Sep 17, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 7, 2019

fix #13037

As user described in the issue the user path behaviour didn't quite make sense. For example in an update we copied over config/global.php and config/global.ini.php to the user path. This may fail though due to write permission and is generally not needed cause the only files it should load from there is config/config.php and config/config.ini.php and config/common.config.ini.php.

This makes things a lot simpler and now there is an easy way to put the config file outside Matomo webroot.

Should probably also create an FAQ for this afterwards.

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Sep 7, 2019
@tsteur tsteur added this to the 3.12.0 milestone Sep 7, 2019
@@ -40,7 +40,9 @@ public static function checkDirectoriesWritable($directoriesToCheck)
{
$resultCheck = array();
foreach ($directoriesToCheck as $directoryToCheck) {
if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)) {
if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)
Copy link
Member Author

Choose a reason for hiding this comment

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

those 3 constant might point to different directories so we need to only add another directory if none of these are set

require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
}

if (!defined('PIWIK_INCLUDE_PATH')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

same behaviour now as in index.php as bootstrap.php could change the user path

@@ -15,12 +15,8 @@
use Piwik\Tests\Framework\TestingEnvironmentManipulator;
use Piwik\Tests\Framework\TestingEnvironmentVariables;

if (!defined('PIWIK_INCLUDE_PATH')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

these constants are now removed as they are detected and set by index.php

@@ -298,11 +298,6 @@ private function installNewFiles($extractedArchiveDirectory)
$model->removeGoneFiles($extractedArchiveDirectory, PIWIK_DOCUMENT_ROOT);
}

// Config files may be user (account) specific
if (PIWIK_INCLUDE_PATH !== PIWIK_USER_PATH) {
Copy link
Member Author

Choose a reason for hiding this comment

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

no longer needed to copy the global config files over as there might not be write permission anyway and it's not needed. They should be always in document root.

@diosmosis diosmosis merged commit 42b4ab1 into 3.x-dev Sep 17, 2019
@diosmosis diosmosis deleted the userpathfix branch September 17, 2019 20:35
@mattab
Copy link
Member

mattab commented Oct 25, 2019

Should probably also create an FAQ for this afterwards.

@tsteur if you have a FAQ draft let me know, happy to publish it 👍

@tsteur
Copy link
Member Author

tsteur commented Oct 25, 2019

It was already there kind of

@florianjacob
Copy link
Contributor

This made it impossible to use PIWIK_USER_PATH as an instance-specific writable location, separated from a shared, read-only PIWIK_DOCUMENT_ROOT: #15087

kaystrobach pushed a commit to kaystrobach/TYPO3.piwikintegration that referenced this pull request Jan 10, 2020
* Make sure PIWIK_DOCUMENT_ROOT gets defined

Without this, calling a frontend site fails with the following PHP error 

Use of undefined constant PIWIK_DOCUMENT_ROOT - assumed 'PIWIK_DOCUMENT_ROOT' (this will throw an Error in a future version of PHP) in piwik\core\Config.php on line 111
...
PHP Warning:  require(PIWIK_DOCUMENT_ROOT/config/global.php): failed to open stream: No such file or directory in ...

The problem is caused by matomo-org/matomo#14866 Make sure to define PIWIK_DOCUMENT_ROOT before it is used.

* Update Install.php

* Update ext_localconf.php

* Update ext_localconf.php

* Update Install.php
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 not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

global(.ini).php in local PIWIK_USER_PATH not updated (composer)
4 participants