Fix dist urls for lock files and hardcoded references
parent
8a35353e8d
commit
027037bb9f
|
@ -85,8 +85,12 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function processUrl($url)
|
||||
protected function processUrl(PackageInterface $package, $url)
|
||||
{
|
||||
if ($package->getDistReference() && preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
|
||||
$url = 'https://github.com/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
|
||||
}
|
||||
|
||||
if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
|
||||
// bypass https for github if openssl is disabled
|
||||
if (preg_match('{^https?://(github.com/[^/]+/[^/]+/(zip|tar)ball/[^/]+)$}i', $url, $match)) {
|
||||
|
@ -96,7 +100,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
return parent::processUrl($package, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ class FileDownloader implements DownloaderInterface
|
|||
|
||||
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
||||
|
||||
$processUrl = $this->processUrl($url);
|
||||
$processUrl = $this->processUrl($package, $url);
|
||||
|
||||
try {
|
||||
$this->rfs->copy($package->getSourceUrl(), $processUrl, $fileName);
|
||||
|
@ -123,12 +123,13 @@ class FileDownloader implements DownloaderInterface
|
|||
/**
|
||||
* Process the download url
|
||||
*
|
||||
* @param PackageInterface $package package the url is coming from
|
||||
* @param string $url download url
|
||||
* @return string url
|
||||
*
|
||||
* @throws \RuntimeException If any problem with the url
|
||||
*/
|
||||
protected function processUrl($url)
|
||||
protected function processUrl(PackageInterface $package, $url)
|
||||
{
|
||||
if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
|
||||
throw new \RuntimeException('You must enable the openssl extension to download files via https');
|
||||
|
|
|
@ -481,6 +481,7 @@ class Installer
|
|||
$references = $this->package->getReferences();
|
||||
if (isset($references[$package->getName()])) {
|
||||
$package->setSourceReference($references[$package->getName()]);
|
||||
$package->setDistReference($references[$package->getName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ArchiveDownloaderTest extends \PHPUnit_Framework_TestCase
|
|||
$method->setAccessible(true);
|
||||
|
||||
$expected = 'https://github.com/composer/composer/zipball/master';
|
||||
$url = $method->invoke($downloader, $expected);
|
||||
$url = $method->invoke($downloader, $this->getMock('Composer\Package\PackageInterface'), $expected);
|
||||
|
||||
if (extension_loaded('openssl')) {
|
||||
$this->assertEquals($expected, $url);
|
||||
|
|
Loading…
Reference in New Issue