From dad7f89fd580c27eb11b52f4933f94115ae530bb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Mar 2017 08:53:39 +0100 Subject: [PATCH 1/5] Fix docs, fixes #6136 --- src/Composer/Script/ScriptEvents.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Script/ScriptEvents.php b/src/Composer/Script/ScriptEvents.php index 7ae1fea26..491c6bc65 100644 --- a/src/Composer/Script/ScriptEvents.php +++ b/src/Composer/Script/ScriptEvents.php @@ -95,7 +95,7 @@ class ScriptEvents /** * The POST_ROOT_PACKAGE_INSTALL event occurs after the root package has been installed. * - * The event listener method receives a Composer\Installer\PackageEvent instance. + * The event listener method receives a Composer\Script\Event instance. * * @var string */ @@ -105,7 +105,7 @@ class ScriptEvents * The POST_CREATE_PROJECT event occurs after the create-project command has been executed. * Note: Event occurs after POST_INSTALL_CMD * - * The event listener method receives a Composer\Installer\PackageEvent instance. + * The event listener method receives a Composer\Script\Event instance. * * @var string */ From 4b11bbccef83e7a188ff599bb531239ec86faaa4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Mar 2017 09:01:07 +0100 Subject: [PATCH 2/5] Add note about requiring composer for plugin dev, fixes #6132 --- doc/articles/custom-installers.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/articles/custom-installers.md b/doc/articles/custom-installers.md index a3c937a5e..791c04956 100644 --- a/doc/articles/custom-installers.md +++ b/doc/articles/custom-installers.md @@ -85,10 +85,16 @@ Example: }, "require": { "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "^1.3" } } ``` +The example above has Composer itself in its require-dev, which allows you to use +the Composer classes in your test suite for example. + ### The Plugin class The class defining the Composer plugin must implement the From 1baa2a52d43bac41d2e8435b9d16c8296665051f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Mar 2017 10:45:03 +0100 Subject: [PATCH 3/5] Make sure script running errors are always output even in quiet mode, fixes #6122 --- src/Composer/EventDispatcher/EventDispatcher.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index b74d34858..753446e44 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -177,13 +177,13 @@ class EventDispatcher if (substr($callable, 0, 10) === '@composer ') { $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); if (0 !== ($exitCode = $this->process->execute($exec))) { - $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName())); + $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET); throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode); } } else { if (!$this->getListeners(new Event($scriptName))) { - $this->io->writeError(sprintf('You made a reference to a non-existent script %s', $callable)); + $this->io->writeError(sprintf('You made a reference to a non-existent script %s', $callable), true, IOInterface::QUIET); } $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags)); @@ -193,11 +193,11 @@ class EventDispatcher $methodName = substr($callable, strpos($callable, '::') + 2); if (!class_exists($className)) { - $this->io->writeError('Class '.$className.' is not autoloadable, can not call '.$event->getName().' script'); + $this->io->writeError('Class '.$className.' is not autoloadable, can not call '.$event->getName().' script', true, IOInterface::QUIET); continue; } if (!is_callable($callable)) { - $this->io->writeError('Method '.$callable.' is not callable, can not call '.$event->getName().' script'); + $this->io->writeError('Method '.$callable.' is not callable, can not call '.$event->getName().' script', true, IOInterface::QUIET); continue; } @@ -205,7 +205,7 @@ class EventDispatcher $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0; } catch (\Exception $e) { $message = "Script %s handling the %s event terminated with an exception"; - $this->io->writeError(''.sprintf($message, $callable, $event->getName()).''); + $this->io->writeError(''.sprintf($message, $callable, $event->getName()).'', true, IOInterface::QUIET); throw $e; } } else { @@ -233,7 +233,7 @@ class EventDispatcher } if (0 !== ($exitCode = $this->process->execute($exec))) { - $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName())); + $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET); throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode); } From 9be13783a3515c0b1246d9e2fe8972d9f85b592f Mon Sep 17 00:00:00 2001 From: James Buncle Date: Fri, 17 Feb 2017 16:07:08 +0000 Subject: [PATCH 4/5] Updated VersionGuesser to check if we actually have a version in the returned array (fixes bug originating from f6899e5 when array was first introduced) - as SVN Versions not being guessed as it would previously stop at Git check. Fixes #6178 --- src/Composer/Package/Version/VersionGuesser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index ce030ff0e..011ac376d 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -65,17 +65,17 @@ class VersionGuesser { if (function_exists('proc_open')) { $versionData = $this->guessGitVersion($packageConfig, $path); - if (null !== $versionData) { + if (null !== $versionData && null !== $versionData['version']) { return $versionData; } $versionData = $this->guessHgVersion($packageConfig, $path); - if (null !== $versionData) { + if (null !== $versionData && null !== $versionData['version']) { return $versionData; } $versionData = $this->guessFossilVersion($packageConfig, $path); - if (null !== $versionData) { + if (null !== $versionData && null !== $versionData['version']) { return $versionData; } From 08fc56b38aebfef732f2f64d0607b32b13a98219 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Mar 2017 12:08:51 +0100 Subject: [PATCH 5/5] Avoid using null value as string, fixes #6134 --- src/Composer/Util/RemoteFilesystem.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 5b137686d..e974d69d7 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -348,7 +348,7 @@ class RemoteFilesystem if ($originUrl === 'bitbucket.org' && !$this->isPublicBitBucketDownload($fileUrl) && substr($fileUrl, -4) === '.zip' - && preg_match('{^text/html\b}i', $contentType) + && $contentType && preg_match('{^text/html\b}i', $contentType) ) { $result = false; if ($this->retryAuthFailure) { @@ -385,7 +385,8 @@ class RemoteFilesystem // decode gzip if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) { - $decode = 'gzip' === strtolower($this->findHeaderValue($http_response_header, 'content-encoding')); + $contentEncoding = $this->findHeaderValue($http_response_header, 'content-encoding'); + $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding); if ($decode) { try {