From 007ca5ff6a4f837796c8e270f7b77a9183a0aed5 Mon Sep 17 00:00:00 2001 From: Minh-Quan TRAN Date: Tue, 12 Sep 2017 23:14:01 +0200 Subject: [PATCH 1/5] workaround for gitlab installation with relative url Signed-off-by: Minh-Quan TRAN --- src/Composer/Util/RemoteFilesystem.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 7b0d650bd..a9f788de0 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -195,6 +195,20 @@ class RemoteFilesystem $originUrl = 'github.com'; } + // Gitlab can be installed in a non-root context. When downloading archives the originalUrl is the host without + // the relative path, so we look for the registered gitlab-domains that matching the host here + if (is_array($this->config->get('gitlab-domains')) + && false === strpos($originUrl, '/') + && !in_array($originUrl, $this->config->get('gitlab-domains'))) { + foreach($this->config->get('gitlab-domains') as $gitlabDomain) { + if (0 === strpos($gitlabDomain, $originUrl)) { + $originUrl = $gitlabDomain; + break; + } + } + unset($gitlabDomain); + } + $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME); $this->bytesMax = 0; $this->originUrl = $originUrl; From 11f1e037392035c7983613b5a037ee04993c16ad Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 3 Nov 2017 19:44:44 +0100 Subject: [PATCH 2/5] CS tweaks --- src/Composer/Util/RemoteFilesystem.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index a9f788de0..aa8a45698 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -195,12 +195,14 @@ class RemoteFilesystem $originUrl = 'github.com'; } - // Gitlab can be installed in a non-root context. When downloading archives the originalUrl is the host without - // the relative path, so we look for the registered gitlab-domains that matching the host here - if (is_array($this->config->get('gitlab-domains')) + // Gitlab can be installed in a non-root context (i.e. gitlab.com/foo). When downloading archives the originUrl + // is the host without the path, so we look for the registered gitlab-domains matching the host here + if ( + is_array($this->config->get('gitlab-domains')) && false === strpos($originUrl, '/') - && !in_array($originUrl, $this->config->get('gitlab-domains'))) { - foreach($this->config->get('gitlab-domains') as $gitlabDomain) { + && !in_array($originUrl, $this->config->get('gitlab-domains')) + ) { + foreach ($this->config->get('gitlab-domains') as $gitlabDomain) { if (0 === strpos($gitlabDomain, $originUrl)) { $originUrl = $gitlabDomain; break; From 71c2ecbacefd91864b8b0f349b874e37dce00da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vasseur?= Date: Tue, 26 Sep 2017 15:06:39 +0200 Subject: [PATCH 3/5] Fix platform package detection in VersionParser --- .../Package/Version/VersionParser.php | 3 +- .../Package/Version/VersionParserTest.php | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Package/Version/VersionParserTest.php diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 65791848b..54d7f09c0 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -12,6 +12,7 @@ namespace Composer\Package\Version; +use Composer\Repository\PlatformRepository; use Composer\Semver\VersionParser as SemverVersionParser; class VersionParser extends SemverVersionParser @@ -47,7 +48,7 @@ class VersionParser extends SemverVersionParser for ($i = 0, $count = count($pairs); $i < $count; $i++) { $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i])); - if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/')) { + if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $pairs[$i + 1])) { $pair .= ' '.$pairs[$i + 1]; $i++; } diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php new file mode 100644 index 000000000..4ae2e2a25 --- /dev/null +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -0,0 +1,37 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Package\Version; + +use Composer\Package\Version\VersionParser; + +class VersionParserTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getParseNameVersionPairsData + */ + public function testParseNameVersionPairs($pairs, $result) + { + $versionParser = new VersionParser(); + + $this->assertSame($result, $versionParser->parseNameVersionPairs($pairs)); + } + + public function getParseNameVersionPairsData() + { + return array( + array(array('php:^7.0'), array(array('name' => 'php', 'version' => '^7.0'))), + array(array('php', '^7.0'), array(array('name' => 'php', 'version' => '^7.0'))), + array(array('php', 'ext-apcu'), array(array('name' => 'php'), array('name' => 'ext-apcu'))), + ); + } +} From 02b57ff4a2bac62f9df9c71c641b850f390537e2 Mon Sep 17 00:00:00 2001 From: Mihai Plasoianu Date: Wed, 11 Oct 2017 17:12:40 +0200 Subject: [PATCH 4/5] Return non-zero exit code with --strict and single package --- src/Composer/Command/ShowCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index e9ffbe029..08b05ad6c 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -43,6 +43,7 @@ use Composer\Semver\Semver; * @author Robert Schönthal * @author Jordi Boggiano * @author Jérémy Romey + * @author Mihai Plasoianu */ class ShowCommand extends BaseCommand { @@ -196,9 +197,13 @@ EOT $this->displayPackageTree($package, $installedRepo, $repos); } else { $latestPackage = null; + $exitCode = 0; if ($input->getOption('latest')) { $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion); } + if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) { + $exitCode = 1; + } $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null); $this->printLinks($package, 'requires'); $this->printLinks($package, 'devRequires', 'requires (dev)'); @@ -213,7 +218,7 @@ EOT $this->printLinks($package, 'replaces'); } - return; + return $exitCode; } // show tree view if requested From b1aed48e1ae26de30ad14b874a22fc95bdcfbe8a Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Thu, 2 Nov 2017 13:53:09 +0000 Subject: [PATCH 5/5] Fix bug setting COMPOSER_ORIGINAL_INIS This variable stores the loaded ini file and any additional scanned ini files, separated by a path-separator. The loaded ini file should always be present, even if it is an empty value. Unfortunately I removed any empty value to parse the ini files, then used the truncated list to set the variable. This bug surfaced on docker php images. These do not have a specific php.ini but store all their settings in the location(s) configured at build time using --with-config-file-scan-dir. --- src/Composer/XdebugHandler.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/XdebugHandler.php b/src/Composer/XdebugHandler.php index f7fd8c2a1..e9d719abf 100644 --- a/src/Composer/XdebugHandler.php +++ b/src/Composer/XdebugHandler.php @@ -139,11 +139,6 @@ class XdebugHandler $iniPaths = IniHelper::getAll(); $additional = count($iniPaths) > 1; - if (empty($iniPaths[0])) { - // There is no loaded ini - array_shift($iniPaths); - } - if ($this->writeTmpIni($iniPaths)) { return $this->setEnvironment($additional, $iniPaths); } @@ -156,20 +151,25 @@ class XdebugHandler * * The filename is passed as the -c option when the process restarts. * - * @param array $iniFiles The php.ini locations + * @param array $iniPaths Locations reported by the current process * * @return bool */ - private function writeTmpIni(array $iniFiles) + private function writeTmpIni(array $iniPaths) { if (!$this->tmpIni = tempnam(sys_get_temp_dir(), '')) { return false; } + // $iniPaths has at least one item and it may be empty + if (empty($iniPaths[0])) { + array_shift($iniPaths); + } + $content = ''; $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi'; - foreach ($iniFiles as $file) { + foreach ($iniPaths as $file) { $data = preg_replace($regex, ';$1', file_get_contents($file)); $content .= $data.PHP_EOL; } @@ -203,7 +203,7 @@ class XdebugHandler * Returns true if the restart environment variables were set * * @param bool $additional Whether there were additional inis - * @param array $iniPaths Locations used by the current prcoess + * @param array $iniPaths Locations reported by the current process * * @return bool */