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

Allow bootstrap file to manipulate config settings #15001

Merged
merged 1 commit into from Oct 13, 2019

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Oct 13, 2019

Allows a bootstrap file to change config settings like by creating a bootstrap.php and then having eg

// matomo/bootstrap.php
$GLOBALS['MATOMO_MODIFY_CONFIG_SETTINGS'] = function ($settings) {
	$settings['Plugins'][] = 'MyPlugin';
         return $settings;
});

It's mainly useful to configure the list of plugins as pretty much all other settings can be configured through DI when the config is being created. I was doing this initially here as well for quite some time until I noticed a problem with an incompatible plugin and had to do it this way. The problem is that when changing the list of activated plugins dynamically through DI, then the plugin config.php files aren't loaded correctly. The order is:

  1. Get activated plugins
  2. Load plugin config.php files when building DI container
  3. Run DI container for config class

This means when adding eg TagManager through DI to the list of activated plugins then the config.php of TagManager will never be loaded and it always results in errors. Instead of in step 3 I needed to make the change in step 1.

Not documenting this for now as it would usually never be needed and we don't want to support this just yet.

Allows a bootstrap file to change config settings like by creating a `bootstrap.php` and then having eg 

```php
$GLOBALS['MATOMO_MODIFY_CONFIG_SETTINGS'] = function ($settings) {
	$settings['Plugins'][] = 'MyPlugin';
         return $settings;
});
```

It's mainly useful to configure the list of plugins as pretty much all other settings can be configured through DI when the config is being created. I was doing this initially here as well for quite some time until I noticed a problem with an incompatible plugin and had to do it this way. The problem is that when changing the list of activated plugins dynamically through DI, then the plugin config.php files aren't loaded correctly. The order is:

1. Get activated plugins
2. Load plugin config.php files when building DI container
3. Run DI container for config class

This means when adding eg TagManager through DI to the list of activated plugins then the config.php of TagManager will never be loaded and it always results in errors. Instead of in step 3 I needed to make the change in step 1. 

Not documenting this for now as it would usually never be needed and we don't want to support this just yet.
@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 Oct 13, 2019
@tsteur tsteur added this to the 3.12.0 milestone Oct 13, 2019
@tsteur tsteur merged commit 608cfdb into 3.x-dev Oct 13, 2019
@tsteur tsteur deleted the bootstrapmanipulateconfig branch October 13, 2019 20:45
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.

None yet

1 participant