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
Conversation
@@ -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) |
There was a problem hiding this comment.
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')) { |
There was a problem hiding this comment.
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')) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
@tsteur if you have a FAQ draft let me know, happy to publish it 👍 |
It was already there kind of |
This made it impossible to use |
* 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
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
andconfig/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 isconfig/config.php
andconfig/config.ini.php
andconfig/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.