-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Encapsulate plugins from using Matomo dependencies directly by introducing vendor proxy patterns #20596
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
Conversation
a7c1fee
to
cb5bd07
Compare
@bx80 @michalkleiner Feel free to already have a look at this one and give feedback if you have any ideas how to change or improve that. Most stuff should already be finished. But I need to have another look through the plugins to check if any might use some vendor lib that isn't proxied yet. |
That certainly is a big change, will look through it. I already have two questions:
|
Matomo plugins will need to work with the versions of dependencies used by Matomo core. When Matomo is being used in a WordPress plugin, where other WordPress plugins may have loaded different version of the dependencies, then Matomo core can use dependency prefixing to avoid conflicts.
This change isn't adding the prefixing, but is a first step to make sure that all Matomo plugins are using a vendor proxy class in core to access dependencies. This is the breaking change as Matomo plugins will need to be updated and so needs to be part of a major release, the actual prefixing change can be done later after the major release. Prefixing could also just be done for Matomo for WordPress and not for normal installs. (that's my understanding anyway! 🙂 ) |
The proxy classes should prevent that plugins need to use any class (or namespaced method) from a dependency directly. The requirement is more to be able to prefix the vendor libs if needed, without breaking plugins, than fully hiding our dependencies. And I didn't use any tool for the changes. Some of the stuff can be easily replaced with regexes, but some stuff needs to be looked at manually I guess. |
Yes, though ultimately that dependency still need to be installed by Composer and the same 'version resolution'-related issue could occur if I understood the problem right. Would we need to add any Composer dependencies to core while moving them from the plugins? Or it is basically limited to dependencies that we already have/know about? This might surface once the core/maintained plugins are updated to use the proxy classes.
All good, I might try a quick Rector run to see what it produces, just to gauge the effort and compare the outcomes. That shouldn't hold this PR though. |
@michalkleiner Matomo itself uses a fixed set a composer dependencies. We have even committed the composer.lock to ensure it always installs the same version. Plugins are still allowed to have their own dependencies. But from Matomo 5 on we will recommend to use php-scoper to prefix all vendors of a plugin to ensure they can't conflict with another wordpress plugin or even with core if we decide to add new vendor libs. |
Thanks for explaining and having patience with me, @sgiehl! |
e98d9e6
to
796e2cb
Compare
@michalkleiner @bx80 The changes in the PR should now be complete. It would be good if one or even both of you would do an intense review of this PR. As it contains a lot (breaking) changes it's important to check that everything still works. Especially some commands could be broken now. We unfortunately don't have many tests for our commands, so we might need to test some of them manually to prove they still work or maybe add some tests if important commands don't have any. If you both think the changes are fine we can merge this PR so we can finish the required adjustments in the plugins. Note: As some of the plugins are included as submodules in core, the PRs for those plugins need to be merged first, so we can update the submodule references here. Otherwise it can happen that we end up with invalid references as the submodules in this PR target certain branches that might get deleted after their PRs are merged. I also didn't have enough time to check if any plugin might use another core dependency. But we can add additional proxy classes later if that might be required. In the end a quick summary of the todos:
|
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
…usage of ConfirmationQuestion)
…d output interfaces
without using InputOption constants
without using InputArgument constants
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
Description:
Documentation & Migration guide will be added in matomo-org/developer-documentation#712
Review