From 750172dc4c34f172ae1ed912977e5e8333b5eccb Mon Sep 17 00:00:00 2001 From: Ingo Fabbri Date: Thu, 27 Aug 2020 18:13:53 +0200 Subject: [PATCH 1/4] Fix symlink check Given you have a symlink in one of your path repositories and mirroring-strategy enabled. ```bash lrwxrwxrwx 1 inf inf 8 27. Aug 17:41 Create.html -> New.html -rw-r--r-- 1 inf inf 750 27. Aug 17:24 Edit.html -rw-r--r-- 1 inf inf 0 27. Aug 17:24 List.html -rw-r--r-- 1 inf inf 5064 27. Aug 17:24 New.html -rw-r--r-- 1 inf inf 716 27. Aug 17:24 Show.html ``` `$file->getLinkTarget()` just returns a relative path in this example. It does not return an absolute normalized path. `$sources` is always a normalized path. `strpos` can never be `0`. Use `$file->getRealPath()` to fix the strpos-check. --- src/Composer/Package/Archiver/ArchivableFilesFinder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchivableFilesFinder.php b/src/Composer/Package/Archiver/ArchivableFilesFinder.php index 150e5f48e..4a8042abe 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFinder.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFinder.php @@ -43,7 +43,7 @@ class ArchivableFilesFinder extends \FilterIterator { $fs = new Filesystem(); - $sources = $fs->normalizePath($sources); + $sources = $fs->normalizePath(realpath($sources)); if ($ignoreFilters) { $filters = array(); @@ -58,7 +58,7 @@ class ArchivableFilesFinder extends \FilterIterator $this->finder = new Finder(); $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) { - if ($file->isLink() && strpos($file->getLinkTarget(), $sources) !== 0) { + if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) { return false; } From e68b52697b73630df03a4e7706fc6e01f00d2120 Mon Sep 17 00:00:00 2001 From: TerryKern <56536101+terrykern@users.noreply.github.com> Date: Tue, 20 Oct 2020 11:48:51 +0200 Subject: [PATCH 2/4] Improve readability of version info message Instead of: > You are already using composer version 1.10.15 (1 channel). it shows: > You are already using composer version 1.10.15 (1.x channel). --- src/Composer/Command/SelfUpdateCommand.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 348451e76..4802afcd1 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -177,7 +177,17 @@ EOT } if (Composer::VERSION === $updateVersion) { - $io->writeError(sprintf('You are already using composer version %s (%s channel).', $updateVersion, $versionsUtil->getChannel())); + $channelString = $versionsUtil->getChannel(); + if (is_numeric($channelString)) { + $channelString .= '.x'; + } + $io->writeError( + sprintf( + 'You are already using composer version %s (%s channel).', + $updateVersion, + $channelString + ) + ); // remove all backups except for the most recent, if any if ($input->getOption('clean-backups')) { From 0466add822feb1204e6526578614e72e130a8656 Mon Sep 17 00:00:00 2001 From: "terry.kern" Date: Thu, 22 Oct 2020 14:41:16 +0200 Subject: [PATCH 3/4] Also use channel string for update message https://github.com/composer/composer/pull/9305#issuecomment-714381153 --- src/Composer/Command/SelfUpdateCommand.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 4802afcd1..0f5fb16fb 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -176,11 +176,12 @@ EOT return 1; } + $channelString = $versionsUtil->getChannel(); + if (is_numeric($channelString)) { + $channelString .= '.x'; + } + if (Composer::VERSION === $updateVersion) { - $channelString = $versionsUtil->getChannel(); - if (is_numeric($channelString)) { - $channelString .= '.x'; - } $io->writeError( sprintf( 'You are already using composer version %s (%s channel).', @@ -208,7 +209,7 @@ EOT $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion); - $io->write(sprintf("Updating to version %s (%s channel).", $updateVersion, $versionsUtil->getChannel())); + $io->write(sprintf("Updating to version %s (%s channel).", $updateVersion, $channelString)); $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar'); $signature = $remoteFilesystem->getContents(self::HOMEPAGE, $remoteFilename.'.sig', false); $io->writeError(' ', false); From 8e9262f12986d434aa7572334656cfd58de81abf Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 22 Oct 2020 15:13:01 +0200 Subject: [PATCH 4/4] Enhance the doc about provide to reduce mistakes --- doc/04-schema.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/04-schema.md b/doc/04-schema.md index ecff3d996..c3153e8a8 100644 --- a/doc/04-schema.md +++ b/doc/04-schema.md @@ -442,9 +442,15 @@ that exact version, and not any other version, which would be incorrect. #### provide List of other packages that are provided by this package. This is mostly -useful for common interfaces. A package could depend on some virtual -`logger` package, any library that implements this logger interface would -simply list it in `provide`. +useful for implementations of common interfaces. A package could depend on +some virtual `logger-implementation` package, any library that implements +this logger interface would simply list it in `provide`. +Using `provide` with the name of an actual package rather than a virtual one +implies that the code of that package is also shipped, in which case `replace` +is generally a better choice. A common convention for packages providing an +interface and relying on other packages to provide an implementation (for +instance the PSR interfaces) is to use a `-implementation` suffix for the +name of the virtual package corresponding to the interface package. #### suggest