Fix bug when plugin defines multiple PluginInterface classes #12226
+21
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have a composer plugin that defines multiple
PluginInterface
classes incomposer.json
as mentioned in the docs.However, there is a bug when upgrading between versions of the plugin when there are multiple classes defined.
For example, assume this is the
composer.json
in version 1.0.0.And then in 2.0.0, we consolidate the functionality into one single class:
When we run
composer update
, the 1.0.0 package is activated before it's removed, but only a reference toThirdPlugin
will be kept in$this->registeredPlugins[$package->getName()]
, and so onlyThirdPlugin
is deactivated.Thus
FirstPlugin
andSecondPlugin
are still called, which will cause an error if those classes aren't self-contained and depend on functionality removed in 2.0.0.Hopefully the explanation is clear, but I can create a reproduction demo tomorrow if you'd like. I also haven't run unit tests or phpstan yet, but will wait for the workflows.