Skip to content

Backport of MAGETWO-59256 for 2.1: Custom composer modules break Component Manager #6718 #9692

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

Merged
merged 4 commits into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions setup/src/Magento/Setup/Model/PackagesData.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function getPackagesForInstall()
}

/**
* Get MetaPackage for package
*
* @param array $packages
* @return array
Expand Down Expand Up @@ -377,26 +378,38 @@ private function getPackageAvailableVersions($package)

return array_keys($packageVersions);
}
} else {
$versionsPattern = '/^versions\s*\:\s(.+)$/m';

$commandParams = [
self::PARAM_COMMAND => self::COMPOSER_SHOW,
self::PARAM_PACKAGE => $package,
self::PARAM_AVAILABLE => true
];

$applicationFactory = $this->objectManagerProvider->get()
->get('Magento\Framework\Composer\MagentoComposerApplicationFactory');
/** @var \Magento\Composer\MagentoComposerApplication $application */
$application = $applicationFactory->create();

$result = $application->runComposerCommand($commandParams);
$matches = [];
preg_match($versionsPattern, $result, $matches);
if (isset($matches[1])) {
return explode(', ', $matches[1]);
}
}

return $this->getAvailableVersionsFromAllRepositories($package);
}

/**
* Get available versions of package by "composer show" command
*
* @param string $package
* @return array
* @exception \RuntimeException
*/
private function getAvailableVersionsFromAllRepositories($package)
{
$versionsPattern = '/^versions\s*\:\s(.+)$/m';

$commandParams = [
self::PARAM_COMMAND => self::COMPOSER_SHOW,
self::PARAM_PACKAGE => $package,
self::PARAM_AVAILABLE => true
];

$applicationFactory = $this->objectManagerProvider->get()
->get(\Magento\Framework\Composer\MagentoComposerApplicationFactory::class);
/** @var \Magento\Composer\MagentoComposerApplication $application */
$application = $applicationFactory->create();

$result = $application->runComposerCommand($commandParams);
$matches = [];
preg_match($versionsPattern, $result, $matches);
if (isset($matches[1])) {
return explode(', ', $matches[1]);
}

throw new \RuntimeException(
Expand Down