From 658685744b776d773d38dcc27e7872aad430b74c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 May 2018 17:17:22 -0700 Subject: [PATCH 1/4] Force "C" locale to prevent issue with turkish "I" --- bin/composer | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/composer b/bin/composer index 0664e04ce..57baebc2e 100755 --- a/bin/composer +++ b/bin/composer @@ -5,6 +5,7 @@ if (PHP_SAPI !== 'cli') { echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; } +setlocale(LC_ALL, 'C'); require __DIR__.'/../src/bootstrap.php'; use Composer\Factory; From 3b9d6769bfc5f25e0d08574d615b6beb1024379a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 4 May 2018 10:55:52 +0200 Subject: [PATCH 2/4] Fix class names in comments being parsed in short_open_tags files, fixes #7289 --- src/Composer/Autoload/ClassMapGenerator.php | 4 ++++ tests/Composer/Test/Autoload/ClassMapGeneratorTest.php | 8 -------- .../Autoload/Fixtures/classmap/ShortOpenTagDocblock.php | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 5ff23921c..5d937433b 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -179,6 +179,10 @@ class ClassMapGenerator if (false !== $pos && false === strpos(substr($contents, $pos), ' realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php', ); - /** - * @wontfix If short_open_tag is not enabled, we end up parsing the docblock because - * php_strip_whitespace won't recognize the file. Funky edge-case (does not apply to HHVM). - */ - if (!defined('HHVM_VERSION') && !ini_get('short_open_tag')) { - $classmap['description'] = realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php'; - } - $data = array( array(__DIR__ . '/Fixtures/Namespaced', array( 'Namespaced\\Bar' => realpath(__DIR__) . '/Fixtures/Namespaced/Bar.inc', diff --git a/tests/Composer/Test/Autoload/Fixtures/classmap/ShortOpenTagDocblock.php b/tests/Composer/Test/Autoload/Fixtures/classmap/ShortOpenTagDocblock.php index 72464eaf7..0142ca45e 100644 --- a/tests/Composer/Test/Autoload/Fixtures/classmap/ShortOpenTagDocblock.php +++ b/tests/Composer/Test/Autoload/Fixtures/classmap/ShortOpenTagDocblock.php @@ -2,4 +2,5 @@ /** * Some class description here. */ +// other class name in comment class ShortOpenTagDocblock {} From 78ae0a97f70c2b157d3abea348d14fa7ace96ef3 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 4 May 2018 11:02:02 +0200 Subject: [PATCH 3/4] Terminate quoted strings --- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index c676263a8..75cbcd058 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -1334,10 +1334,10 @@ EOF; file_put_contents($this->workingDir.'/forks/bar/src/exclude/FooExclClass.php', 'workingDir.'/forks/bar/'; - $link = $this->workingDir.'/composersrc/foo/bar/'; + $link = $this->workingDir.'/composersrc/foo/bar'; $command = Platform::isWindows() - ? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) - : 'ln -s "' . $target . '" "' . $link; + ? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) . '"' + : 'ln -s "' . $target . '" "' . $link . '"'; exec($command); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); From e697293cd93a8c47bded63c0f2a04f2c68306fae Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 4 May 2018 11:17:43 +0200 Subject: [PATCH 4/4] Handle broken symlinks more cleanly, fixes #7255 --- src/Composer/Installer/LibraryInstaller.php | 13 ++++++++++++- src/Composer/Util/Filesystem.php | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 4b1a95546..34fbbbee4 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -18,6 +18,7 @@ use Composer\Repository\InstalledRepositoryInterface; use Composer\Package\PackageInterface; use Composer\Util\Filesystem; use Composer\Util\Silencer; +use Composer\Util\Platform; /** * Package installation manager. @@ -71,7 +72,17 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface */ public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) { - return $repo->hasPackage($package) && is_readable($this->getInstallPath($package)); + if (!$repo->hasPackage($package)) { + return false; + } + + $installPath = $this->getInstallPath($package); + + if (is_readable($installPath)) { + return true; + } + + return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath); } /** diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 9e0e37279..2daa1ceb1 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -103,6 +103,10 @@ class Filesystem return $this->removeJunction($directory); } + if (is_link($directory)) { + return unlink($directory); + } + if (!file_exists($directory) || !is_dir($directory)) { return true; }