-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix false-positive when determining if patcher (current package) is going to be uninstalled #101
base: release/3
Are you sure you want to change the base?
Conversation
…oing to be uninstalled When a package that is really going to be deleted defines a "Vaimo" namespace in its PSR-4 autoload, then vaimo/composer patches decides that it is going to be deleted and wipes out patches. It happens because strpos("Vaimo\ComposerPatches", "Vaimo") indeed returns 0.
9ef04b2
to
e1afb03
Compare
public function isPatcherUninstallOperation(OperationInterface $operation) | ||
{ | ||
if (!$operation instanceof \Composer\DependencyResolver\Operation\UninstallOperation) { | ||
return false; | ||
} | ||
|
||
return $this->configAnalyser->ownsNamespace($operation->getPackage(), __NAMESPACE__); | ||
return \in_array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at adding a test for this change?
Perhaps there is some existing test, which exercises this code, that could be the basis for an additional test to show that the "Vaimo namespace case" works as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave up on figuring out how it is tested. It has too smart testing framework and close to no documentation on how to actually use it :(
@@ -15,6 +15,8 @@ class Plugin implements | |||
\Composer\EventDispatcher\EventSubscriberInterface, | |||
\Composer\Plugin\Capable | |||
{ | |||
const COMPOSER_PACKAGE = 'vaimo/composer-patches'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of introducing random constants like that, is it possible to get this information out of composer API in a backward compatible way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not seem possible, because the addPlugin
method does not pass anything about the $sourcePackage
to the plugin's activate method.
I suggest just leaving this as is.
PR looks good to me. Continue with merge? |
When a package that is really going to be deleted defines a "Vaimo" namespace in its PSR-4 autoload,
then vaimo/composer patches decides that it is going to be deleted and wipes out patches.
It happens because strpos("Vaimo\ComposerPatches", "Vaimo") indeed returns 0.
Steps to Reproduce
--dev
dependency in a project that has vaimo/composer-patches installed as production dependencycomposer install --no-dev