Merge branch '4.4' into 5.2
* 4.4: [travis] remove cache of composer.lock for deps=low Fix comment with typo
This commit is contained in:
commit
36cc161adc
|
@ -1,164 +0,0 @@
|
|||
<?php
|
||||
|
||||
error_reporting(-1);
|
||||
set_error_handler(function ($type, $message, $file, $line) {
|
||||
if (error_reporting() & $type) {
|
||||
throw new \ErrorException($message, 0, $type, $file, $line);
|
||||
}
|
||||
});
|
||||
array_shift($_SERVER['argv']);
|
||||
$dirs = $_SERVER['argv'];
|
||||
|
||||
function getRelevantContent(array $composerJson)
|
||||
{
|
||||
$relevantKeys = [
|
||||
'name',
|
||||
'require',
|
||||
'require-dev',
|
||||
'conflict',
|
||||
'replace',
|
||||
'provide',
|
||||
'minimum-stability',
|
||||
'prefer-stable',
|
||||
'repositories',
|
||||
'extra',
|
||||
];
|
||||
|
||||
$relevantContent = [];
|
||||
|
||||
foreach (array_intersect($relevantKeys, array_keys($composerJson)) as $key) {
|
||||
$relevantContent[$key] = $composerJson[$key];
|
||||
}
|
||||
if (isset($composerJson['config']['platform'])) {
|
||||
$relevantContent['config']['platform'] = $composerJson['config']['platform'];
|
||||
}
|
||||
|
||||
return $relevantContent;
|
||||
}
|
||||
|
||||
function getContentHash(array $composerJson)
|
||||
{
|
||||
$relevantContent = getRelevantContent($composerJson);
|
||||
ksort($relevantContent);
|
||||
|
||||
return md5(json_encode($relevantContent));
|
||||
}
|
||||
|
||||
$composerJsons = [];
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!file_exists($dir.'/composer.lock') || !$composerLock = @json_decode(file_get_contents($dir.'/composer.lock'), true)) {
|
||||
@unlink($dir.'/composer.lock');
|
||||
continue;
|
||||
}
|
||||
if (!file_exists($dir.'/composer.json') || !$composerJson = @json_decode(file_get_contents($dir.'/composer.json'), true)) {
|
||||
echo "$dir/composer.json not found or invalid.\n";
|
||||
@unlink($dir.'/composer.lock');
|
||||
continue;
|
||||
}
|
||||
if (!isset($composerLock['content-hash']) || getContentHash($composerJson) !== $composerLock['content-hash']) {
|
||||
echo "$dir/composer.lock is outdated.\n";
|
||||
@unlink($dir.'/composer.lock');
|
||||
continue;
|
||||
}
|
||||
$composerLock += ['packages' => [], 'packages-dev' => []];
|
||||
$composerJsons[$composerJson['name']] = [$dir, $composerLock['packages'] + $composerLock['packages-dev'], getRelevantContent($composerJson)];
|
||||
}
|
||||
|
||||
$referencedCommits = [];
|
||||
|
||||
foreach ($composerJsons as [$dir, $lockedPackages]) {
|
||||
foreach ($lockedPackages as $lockedJson) {
|
||||
if (0 !== strpos($version = $lockedJson['version'], 'dev-') && '-dev' !== substr($version, -4)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($composerJsons[$name = $lockedJson['name']])) {
|
||||
echo "$dir/composer.lock references missing $name.\n";
|
||||
@unlink($dir.'/composer.lock');
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (isset($composerJsons[$name][2]['repositories']) && !isset($lockedJson['repositories'])) {
|
||||
// the locked package has been patched locally but the lock references a commit,
|
||||
// which means the referencing package itself is not modified
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (['minimum-stability', 'prefer-stable'] as $key) {
|
||||
if (array_key_exists($key, $composerJsons[$name][2])) {
|
||||
$lockedJson[$key] = $composerJsons[$name][2][$key];
|
||||
}
|
||||
}
|
||||
|
||||
// use weak comparison to ignore ordering
|
||||
if (getRelevantContent($lockedJson) != $composerJsons[$name][2]) {
|
||||
echo "$dir/composer.lock is not in sync with $name.\n";
|
||||
@unlink($dir.'/composer.lock');
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if ($lockedJson['dist']['reference']) {
|
||||
$referencedCommits[$name][$lockedJson['dist']['reference']][] = $dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$referencedCommits) {
|
||||
return;
|
||||
}
|
||||
|
||||
@mkdir($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org', 0777, true);
|
||||
|
||||
$ch = null;
|
||||
$mh = curl_multi_init();
|
||||
$sh = curl_share_init();
|
||||
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
|
||||
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
|
||||
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
|
||||
$chs = [];
|
||||
|
||||
foreach ($referencedCommits as $name => $dirsByCommit) {
|
||||
foreach (['', '~dev'] as $suffix) {
|
||||
$chs[] = $ch = [curl_init(), fopen($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '~').$suffix.'.json', 'w')];
|
||||
curl_setopt($ch[0], CURLOPT_URL, 'https://repo.packagist.org/p2/'.$name.$suffix.'.json');
|
||||
curl_setopt($ch[0], CURLOPT_FILE, $ch[1]);
|
||||
curl_setopt($ch[0], CURLOPT_SHARE, $sh);
|
||||
curl_multi_add_handle($mh, $ch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
curl_multi_exec($mh, $active);
|
||||
curl_multi_select($mh);
|
||||
} while ($active);
|
||||
|
||||
foreach ($chs as [$ch, $fd]) {
|
||||
curl_multi_remove_handle($mh, $ch);
|
||||
curl_close($ch);
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
foreach ($referencedCommits as $name => $dirsByCommit) {
|
||||
foreach (['', '~dev'] as $suffix) {
|
||||
$repo = file_get_contents($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '~').$suffix.'.json');
|
||||
$repo = json_decode($repo, true);
|
||||
|
||||
foreach ($repo['packages'][$name] as $version) {
|
||||
if (isset($version['source']['reference'])) {
|
||||
unset($referencedCommits[$name][$version['source']['reference']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($referencedCommits as $name => $dirsByCommit) {
|
||||
foreach ($dirsByCommit as $dirs) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir.'/composer.lock')) {
|
||||
echo "$dir/composer.lock references old commit for $name.\n";
|
||||
@unlink($dir.'/composer.lock');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -279,11 +279,7 @@ install:
|
|||
|
||||
[[ ! $X ]] || (exit 1)
|
||||
elif [[ $deps = low ]]; then
|
||||
[[ -e ~/php-ext/composer-lowest.lock.tar ]] && tar -xf ~/php-ext/composer-lowest.lock.tar
|
||||
tar -cf ~/php-ext/composer-lowest.lock.tar --files-from /dev/null
|
||||
php .github/rm-invalid-lowest-lock-files.php $COMPONENTS
|
||||
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'"
|
||||
echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock
|
||||
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
|
||||
else
|
||||
if [[ $PHP = 8.0* ]]; then
|
||||
# add return types before running the test suite
|
||||
|
|
|
@ -1762,7 +1762,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Normalize the given path (transform each blackslash into a real directory separator).
|
||||
* Normalize the given path (transform each forward slash into a real directory separator).
|
||||
*/
|
||||
private function normalize(string $path): string
|
||||
{
|
||||
|
|
Reference in New Issue