Fix pre/post-package-install/update/uninstall events receiving a partial list of operations, fixes #9079
parent
c3db4614c9
commit
f18d91bd58
|
@ -292,14 +292,12 @@ class InstallationManager
|
||||||
if ($batch) {
|
if ($batch) {
|
||||||
$batches[] = $batch;
|
$batches[] = $batch;
|
||||||
}
|
}
|
||||||
unset($operations[$index]);
|
|
||||||
$batches[] = array($index => $operation);
|
$batches[] = array($index => $operation);
|
||||||
$batch = array();
|
$batch = array();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($operations[$index]);
|
|
||||||
$batch[$index] = $operation;
|
$batch[$index] = $operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +306,7 @@ class InstallationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($batches as $batch) {
|
foreach ($batches as $batch) {
|
||||||
$this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts);
|
$this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$runCleanup();
|
$runCleanup();
|
||||||
|
@ -336,7 +334,11 @@ class InstallationManager
|
||||||
$repo->write($devMode, $this);
|
$repo->write($devMode, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts)
|
/**
|
||||||
|
* @param array $operations List of operations to execute in this batch
|
||||||
|
* @param array $allOperations Complete list of operations to be executed in the install job, used for event listeners
|
||||||
|
*/
|
||||||
|
private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
|
||||||
{
|
{
|
||||||
foreach ($operations as $index => $operation) {
|
foreach ($operations as $index => $operation) {
|
||||||
$opType = $operation->getOperationType();
|
$opType = $operation->getOperationType();
|
||||||
|
@ -363,7 +365,7 @@ class InstallationManager
|
||||||
|
|
||||||
$event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
|
$event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
|
||||||
if (defined($event) && $runScripts && $this->eventDispatcher) {
|
if (defined($event) && $runScripts && $this->eventDispatcher) {
|
||||||
$this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $operations, $operation);
|
$this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dispatcher = $this->eventDispatcher;
|
$dispatcher = $this->eventDispatcher;
|
||||||
|
@ -378,12 +380,12 @@ class InstallationManager
|
||||||
$promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
|
$promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
|
||||||
return $installManager->$opType($repo, $operation);
|
return $installManager->$opType($repo, $operation);
|
||||||
})->then($cleanupPromises[$index])
|
})->then($cleanupPromises[$index])
|
||||||
->then(function () use ($opType, $runScripts, $dispatcher, $installManager, $devMode, $repo, $operations, $operation) {
|
->then(function () use ($opType, $runScripts, $dispatcher, $installManager, $devMode, $repo, $allOperations, $operation) {
|
||||||
$repo->write($devMode, $installManager);
|
$repo->write($devMode, $installManager);
|
||||||
|
|
||||||
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
|
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
|
||||||
if (defined($event) && $runScripts && $dispatcher) {
|
if (defined($event) && $runScripts && $dispatcher) {
|
||||||
$dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $operations, $operation);
|
$dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
|
||||||
}
|
}
|
||||||
}, function ($e) use ($opType, $package, $io) {
|
}, function ($e) use ($opType, $package, $io) {
|
||||||
$io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
|
$io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
|
||||||
|
|
Loading…
Reference in New Issue