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

Make sure plugins in config.ini.php are sorted depending on dependencies #11683

Merged
merged 3 commits into from May 15, 2017

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented May 9, 2017

fix #11681

Please note that this will be only executed when activating or removing a plugin. So existing configs won't be changed. AFAIK there are not really any plugins making much use of this feature and this should be fine and we don't need to run an update to change existing configs. It will only affect in which order the config/config.php files are loaded in each plugin. The actual plugins are still loaded alphabetically by the platform (unless a plugin is required).

@tsteur tsteur added c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Needs Review PRs that need a code review labels May 9, 2017
@tsteur tsteur added this to the 3.0.4 milestone May 9, 2017
@@ -111,10 +114,73 @@ public function sortPlugins(array $plugins)
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);

// sort by name to have a predictable order for those extra plugins
sort($otherPluginsToLoadAfterDefaultPlugins);
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
Copy link
Member Author

Choose a reason for hiding this comment

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

We make sure to sort in natural order and to ignore lower / upper case

$sorted = array();
foreach ($otherPluginsToLoadAfterDefaultPlugins as $pluginName) {
$sorted = $this->sortRequiredPlugin($pluginName, $pluginJsonCache, $otherPluginsToLoadAfterDefaultPlugins, $sorted);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

we cannot use classic usort here as it wouldn't sort correctly when "resolving" dependencies.

@mattab
Copy link
Member

mattab commented May 12, 2017

Tried to test this:

  • Before in config.ini.php I have AbTesting then CustomDimensions listed in this order
  • Editing AbTesting/plugin.json and adding:
  "require": {
    "piwik": ">=3.0.0-b5,<4.0.0-b1",
    "CustomDimensions": "1.0.0"
  },
  • Execute ./console plugin:deactivate AbTesting then ./console plugin:activate AbTesting
  • in config.ini.php I have AbTesting then CustomDimensions listed in this order,
  • But expected the CustomDimensions then AdTesting

Is it supposed to work differently or my test procedure not correct?

@tsteur
Copy link
Member Author

tsteur commented May 12, 2017

Your require looks wrong eg "1.0.0" is not a valid definition afaik. It definitely works see tests and also tested it manually. I would check the test procedure

@mattab
Copy link
Member

mattab commented May 13, 2017

ok I'll check again. Which tests do you refer to?

@tsteur
Copy link
Member Author

tsteur commented May 13, 2017

Forgot to commit the tests, just did

@mattab
Copy link
Member

mattab commented May 15, 2017

  • after fixing my test procedure and setting a valid require with a comparison operator:
  "require": {
    "piwik": ">=3.0.0-b5,<4.0.0-b1",
    "CustomDimensions": ">1.0.0"
  },

Then the re-order works as expected.

And with the now added test file, PR is perfect 👍

@mattab mattab merged commit b18fb82 into 3.x-dev May 15, 2017
@mattab mattab deleted the 11681 branch May 15, 2017 05:02
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. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin config of a required plugin should be loaded before the requiring plugin
2 participants