Merge branch '1.8'

main
Jordi Boggiano 5 years ago
commit 79a300eaac
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -920,6 +920,10 @@ If you use a proxy but it does not support the request_fulluri flag for HTTPS
requests, then you should set this env var to `false` or `0` to prevent Composer
from setting the request_fulluri option.
### COMPOSER_SELF_UPDATE_TARGET
If set, makes the self-update command write the new Composer phar file into that path instead of overwriting itself. Useful for updating Composer on read-only filesystem.
### no_proxy or NO_PROXY
If you are behind a proxy and would like to disable it for certain domains, you

@ -351,6 +351,10 @@ TAGSPUBKEY
@copy($localFilename, $backupTarget);
}
if ($targetFilename = getenv('COMPOSER_SELF_UPDATE_TARGET')) {
$localFilename = realpath($targetFilename) ?: $targetFilename;
}
rename($newFilename, $localFilename);
return null;

@ -108,7 +108,7 @@ class Problem
$msg = "\n - This package requires ".$packageName.$this->constraintToText($constraint).' but ';
if (defined('HHVM_VERSION') || count($available)) {
if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
return $msg . 'your HHVM version does not satisfy that requirement.';
}

@ -401,4 +401,14 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
{
return parent::__toString().' (alias of '.$this->aliasOf->getVersion().')';
}
public function setDistUrl($url)
{
return $this->aliasOf->setDistUrl($url);
}
public function setDistType($type)
{
return $this->aliasOf->setDistType($type);
}
}

@ -358,4 +358,32 @@ interface PackageInterface
* @return array
*/
public function getTransportOptions();
/**
* @param string $reference
*
* @return void
*/
public function setSourceReference($reference);
/**
* @param string $url
*
* @return void
*/
public function setDistUrl($url);
/**
* @param string $type
*
* @return void
*/
public function setDistType($type);
/**
* @param string $reference
*
* @return void
*/
public function setDistReference($reference);
}

@ -562,7 +562,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
protected function canonicalizeUrl($url)
{
if ('/' === $url[0]) {
return preg_replace('{(https?://[^/]+).*}i', '$1' . $url, $this->url);
if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
return $matches[0] . $url;
}
return $this->url;
}
return $url;

@ -204,4 +204,71 @@ class ComposerRepositoryTest extends TestCase
$repository->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library')
);
}
/**
* @dataProvider canonicalizeUrlProvider
*
* @param string $expected
* @param string $url
* @param string $repositoryUrl
*/
public function testCanonicalizeUrl($expected, $url, $repositoryUrl)
{
$repository = new ComposerRepository(
array('url' => $repositoryUrl),
new NullIO(),
FactoryMock::createConfig()
);
$object = new \ReflectionObject($repository);
$method = $object->getMethod('canonicalizeUrl');
$method->setAccessible(true);
// ComposerRepository::__construct ensures that the repository URL has a
// protocol, so reset it here in order to test all cases.
$property = $object->getProperty('url');
$property->setAccessible(true);
$property->setValue($repository, $repositoryUrl);
$this->assertSame($expected, $method->invoke($repository, $url));
}
public function canonicalizeUrlProvider()
{
return array(
array(
'https://example.org/path/to/file',
'/path/to/file',
'https://example.org',
),
array(
'https://example.org/canonic_url',
'https://example.org/canonic_url',
'https://should-not-see-me.test',
),
array(
'file:///path/to/repository/file',
'/path/to/repository/file',
'file:///path/to/repository',
),
array(
// Assert that the repository URL is returned unchanged if it is
// not a URL.
// (Backward compatibility test)
'invalid_repo_url',
'/path/to/file',
'invalid_repo_url',
),
array(
// Assert that URLs can contain sequences resembling pattern
// references as understood by preg_replace() without messing up
// the result.
// (Regression test)
'https://example.org/path/to/unusual_$0_filename',
'/path/to/unusual_$0_filename',
'https://example.org',
),
);
}
}

Loading…
Cancel
Save