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

Support alternative matomo bootstrap file #14887

Merged
merged 2 commits into from Sep 16, 2019
Merged

Support alternative matomo bootstrap file #14887

merged 2 commits into from Sep 16, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 11, 2019

Currently, we allow to put a bootstrap.php file into the root directory of Matomo and then load it as first thing. This allows for example the configuration of a few things that are needed to be set BEFORE we load any config. Such as

  • PIWIK_USER_PATH constant
  • Usage of config cache
  • PIWIK_ENABLE_ERROR_HANDLER
  • PIWIK_PRINT_ERROR_BACKTRACE
  • $GLOBALS['PIWIK_TRACKER_DEBUG']
  • etc.

This works nicely. The problem is when you would like to use Matomo for example as a submodule, or install it through composer, etc... then having a file in Matomo directory doesn't do the trick and you need to have the bootstrap file outside the Matomo directory.

That's why I'm now looking for ../matomo_bootstrap.php. It's not ideal cause what if the next person wants to have it at ../../../matomo_bootstrap.php etc. Ideally there be an environment variable. However, the project I'm working on I cannot make use of environment variables.

I will try to workaround it by putting all files into a new endpoint like my_index.php which then includes matomo_bootstrap.php and matomo/index.php for example but likely this won't work since Matomo will then not know the correct paths anymore...

Also we cannot look for ../bootstrap.php btw since someone might actually use that file for a completely different project and we don't want to load any file by accident that does not belong to Matomo.

Update: I couldn't find a workaround for this because otherwise Matomo gets completely confused with paths etc when embedding Matomo eg in a file index.php by doing like matomo/index.php and as I can't use environment variables or anything else will need this solution. Also I noticed that with such a solution we risk that Matomo thinks it is uninstalled and this be a security issue. An attacker could install Matomo using the attacker's DB credentials and this way get super user access which allows to install plugins etc.

@tsteur tsteur added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Sep 11, 2019
@tsteur tsteur added this to the 3.12.0 milestone Sep 11, 2019
@tsteur tsteur added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Sep 12, 2019
@diosmosis diosmosis merged commit 5bb2cda into 3.x-dev Sep 16, 2019
@diosmosis diosmosis deleted the matomobootstrap branch September 16, 2019 11:16
tsteur added a commit that referenced this pull request Oct 30, 2019
diosmosis pushed a commit that referenced this pull request Nov 4, 2019
diosmosis pushed a commit that referenced this pull request Nov 6, 2019
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.

None yet

2 participants