From 9360e2c18a07a0e002999ff49fd92b0e9be98a5e Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 6 Jan 2022 14:06:38 +0000 Subject: [PATCH 1/4] GitLab: detect repository functionality disabled in Driver (#10440) --- src/Composer/Repository/Vcs/GitLabDriver.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index e775dd269..dd7cb65b2 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -504,6 +504,11 @@ class GitLabDriver extends VcsDriver // force auth as the unauthenticated version of the API is broken if (!isset($json['default_branch'])) { + // GitLab allows you to disable the repository inside a project to use a project only for issues and wiki + if (isset($json['repository_access_level']) && $json['repository_access_level'] === 'disabled') { + throw new TransportException('The GitLab repository is disabled in the project', 400); + } + if (!empty($json['id'])) { $this->isPrivate = false; } From 65c8daa969309e5d9f526f28427bff4b77e417bf Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 7 Jan 2022 09:17:25 +0100 Subject: [PATCH 2/4] Workaround PHP bug with env vars not being read correctly on Windows, fixes #10434 refs https://github.com/php/php-src/issues/7896 --- bin/composer | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/composer b/bin/composer index cee476b6d..32c45bcda 100755 --- a/bin/composer +++ b/bin/composer @@ -65,6 +65,12 @@ if (function_exists('ini_set')) { unset($memoryLimit); } +// Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER +// see https://github.com/php/php-src/issues/7896 +if (Platform::isWindows()) { + $_SERVER = array_merge($_SERVER, array_intersect_ukey($_SERVER, getenv(), 'strcasecmp')); +} + Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0])); ErrorHandler::register(); From 508ac051eced468dc3a37a9da5e54351bcb1d8f4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 7 Jan 2022 09:26:22 +0100 Subject: [PATCH 3/4] Revert "Remove getCode usage as it is not type safe apparently, see https://github.com/phpstan/phpstan-src/pull/795" This reverts commit 84f8fda0c6e75dbaa19b4333e1956ff8c2c09b8f. And other issues fixed by PHPStan 1.3.2 --- src/Composer/Console/Application.php | 2 +- .../DependencyResolver/SolverProblemsException.php | 8 -------- src/Composer/Installer.php | 6 +++--- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index b5af14af8..e7c3a32a5 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -348,7 +348,7 @@ class Application extends BaseApplication return $result; } catch (ScriptExecutionException $e) { - return (int) $e->getCode(); + return $e->getCode(); } catch (\Exception $e) { $ghe = new GithubActionError($this->io); $ghe->emit($e->getMessage()); diff --git a/src/Composer/DependencyResolver/SolverProblemsException.php b/src/Composer/DependencyResolver/SolverProblemsException.php index 27deac4b3..128fbe146 100644 --- a/src/Composer/DependencyResolver/SolverProblemsException.php +++ b/src/Composer/DependencyResolver/SolverProblemsException.php @@ -39,14 +39,6 @@ class SolverProblemsException extends \RuntimeException parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED); } - /** - * @return self::ERROR_DEPENDENCY_RESOLUTION_FAILED - */ - public function getExitCode() - { - return self::ERROR_DEPENDENCY_RESOLUTION_FAILED; - } - /** * @param bool $isVerbose * @param bool $isDevExtraction diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 78329042d..c78dc8fd7 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -455,7 +455,7 @@ class Installer $ghe = new GithubActionError($this->io); $ghe->emit($err."\n".$prettyProblem); - return max(self::ERROR_GENERIC_FAILURE, $e->getExitCode()); + return max(self::ERROR_GENERIC_FAILURE, $e->getCode()); } $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE); @@ -633,7 +633,7 @@ class Installer $ghe = new GithubActionError($this->io); $ghe->emit($err."\n".$prettyProblem); - return max(self::ERROR_GENERIC_FAILURE, $e->getExitCode()); + return max(self::ERROR_GENERIC_FAILURE, $e->getCode()); } $lockTransaction->setNonDevPackages($nonDevLockTransaction); @@ -703,7 +703,7 @@ class Installer $ghe = new GithubActionError($this->io); $ghe->emit($err."\n".$prettyProblem); - return max(self::ERROR_GENERIC_FAILURE, $e->getExitCode()); + return max(self::ERROR_GENERIC_FAILURE, $e->getCode()); } } From 0b436de794123e15d037dc15e3777a19b4a2017a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 7 Jan 2022 09:29:35 +0100 Subject: [PATCH 4/4] Fix last bit phpstan error --- src/Composer/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index c78dc8fd7..5b5489d53 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -633,7 +633,7 @@ class Installer $ghe = new GithubActionError($this->io); $ghe->emit($err."\n".$prettyProblem); - return max(self::ERROR_GENERIC_FAILURE, $e->getCode()); + return $e->getCode(); } $lockTransaction->setNonDevPackages($nonDevLockTransaction);