From aea074308c642e86377a2fa0fef7d0f97e5ebb26 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 16 Jun 2020 14:07:30 +0200 Subject: [PATCH] Update batching to install plugin deps before the plugin (alone an own batch) --- src/Composer/Downloader/ArchiveDownloader.php | 2 +- .../Installer/InstallationManager.php | 31 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index d77d55738..8f7f5ef83 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -95,7 +95,7 @@ abstract class ArchiveDownloader extends FileDownloader $filesystem->unlink($fileName); /** - * Returns the folder content, excluding dotfiles + * Returns the folder content, excluding .DS_Store * * @param string $dir Directory * @return \SplFileInfo[] diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index a9bbe7c3a..7dfb2ff3e 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -283,20 +283,31 @@ class InstallationManager // execute operations in batches to make sure every plugin is installed in the // right order and activated before the packages depending on it are installed - while ($operations) { - $batch = array(); - - foreach ($operations as $index => $operation) { - unset($operations[$index]); - $batch[$index] = $operation; - if (in_array($operation->getOperationType(), array('update', 'install'), true)) { - $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage(); - if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') { - break; + $batches = array(); + $batch = array(); + foreach ($operations as $index => $operation) { + if (in_array($operation->getOperationType(), array('update', 'install'), true)) { + $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage(); + if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') { + if ($batch) { + $batches[] = $batch; } + unset($operations[$index]); + $batches[] = array($index => $operation); + $batch = array(); + + continue; } } + unset($operations[$index]); + $batch[$index] = $operation; + } + if ($batch) { + $batches[] = $batch; + } + + foreach ($batches as $batch) { $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts); } } catch (\Exception $e) {