Merge branch '2.0'
commit
bf73a20bc0
|
@ -405,7 +405,7 @@ EOT
|
|||
}
|
||||
}
|
||||
// handler Ctrl+C for Windows on PHP 7.4+
|
||||
if (function_exists('sapi_windows_set_ctrl_handler')) {
|
||||
if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
|
||||
@mkdir($directory, 0777, true);
|
||||
if ($realDir = realpath($directory)) {
|
||||
sapi_windows_set_ctrl_handler(function () use ($realDir) {
|
||||
|
|
|
@ -228,6 +228,10 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
throw $e;
|
||||
}
|
||||
|
||||
if ($e instanceof MaxFileSizeExceededException) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($e instanceof TransportException) {
|
||||
// if we got an http response with a proper code, then requesting again will probably not help, abort
|
||||
if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
|
||||
|
|
|
@ -208,7 +208,7 @@ class InstallationManager
|
|||
};
|
||||
|
||||
$handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
|
||||
$handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler');
|
||||
$handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
|
||||
$prevHandler = null;
|
||||
$windowsHandler = null;
|
||||
if ($handleInterruptsUnix) {
|
||||
|
|
|
@ -75,6 +75,7 @@ class PluginInstaller extends LibraryInstaller
|
|||
|
||||
return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
|
||||
try {
|
||||
Platform::workaroundFilesystemIssues();
|
||||
$pluginManager->registerPackage($package, true);
|
||||
} catch (\Exception $e) {
|
||||
$self->rollbackInstall($e, $repo, $package);
|
||||
|
|
|
@ -227,7 +227,7 @@ class PluginManager
|
|||
$this->registeredPlugins[$package->getName()] = $installer;
|
||||
} elseif (class_exists($class)) {
|
||||
$plugin = new $class();
|
||||
$this->addPlugin($plugin, $isGlobalPlugin);
|
||||
$this->addPlugin($plugin, $isGlobalPlugin, $package);
|
||||
$this->registeredPlugins[$package->getName()] = $plugin;
|
||||
} elseif ($failOnMissingClasses) {
|
||||
throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
|
||||
|
@ -317,11 +317,19 @@ class PluginManager
|
|||
* programmatically and want to register a plugin class directly this is a valid way
|
||||
* to do it.
|
||||
*
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
* @param PluginInterface $plugin plugin instance
|
||||
* @param ?PackageInterface $sourcePackage Package from which the plugin comes from
|
||||
*/
|
||||
public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false)
|
||||
public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
|
||||
{
|
||||
$this->io->writeError('Loading plugin '.get_class($plugin).($isGlobalPlugin ? ' (installed globally)' : ''), true, IOInterface::DEBUG);
|
||||
$details = array();
|
||||
if ($sourcePackage) {
|
||||
$details[] = 'from '.$sourcePackage->getName();
|
||||
}
|
||||
if ($isGlobalPlugin) {
|
||||
$details[] = 'installed globally';
|
||||
}
|
||||
$this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
|
||||
$this->plugins[] = $plugin;
|
||||
$plugin->activate($this->composer, $this->io);
|
||||
|
||||
|
|
|
@ -377,16 +377,7 @@ class CurlDownloader
|
|||
$e->setResponseInfo($progress);
|
||||
}
|
||||
|
||||
if (is_resource($job['headerHandle'])) {
|
||||
fclose($job['headerHandle']);
|
||||
}
|
||||
if (is_resource($job['bodyHandle'])) {
|
||||
fclose($job['bodyHandle']);
|
||||
}
|
||||
if ($job['filename']) {
|
||||
@unlink($job['filename'].'~');
|
||||
}
|
||||
call_user_func($job['reject'], $e);
|
||||
$this->rejectJob($job, $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,12 +394,12 @@ class CurlDownloader
|
|||
if (isset($this->jobs[$i]['options']['max_file_size'])) {
|
||||
// Compare max_file_size with the content-length header this value will be -1 until the header is parsed
|
||||
if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
|
||||
throw new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
|
||||
$this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
|
||||
}
|
||||
|
||||
// Compare max_file_size with the download size in bytes
|
||||
if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
|
||||
throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
|
||||
$this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -521,6 +512,20 @@ class CurlDownloader
|
|||
return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
|
||||
}
|
||||
|
||||
private function rejectJob(array $job, \Exception $e)
|
||||
{
|
||||
if (is_resource($job['headerHandle'])) {
|
||||
fclose($job['headerHandle']);
|
||||
}
|
||||
if (is_resource($job['bodyHandle'])) {
|
||||
fclose($job['bodyHandle']);
|
||||
}
|
||||
if ($job['filename']) {
|
||||
@unlink($job['filename'].'~');
|
||||
}
|
||||
call_user_func($job['reject'], $e);
|
||||
}
|
||||
|
||||
private function checkCurlResult($code)
|
||||
{
|
||||
if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
|
||||
|
|
|
@ -8,13 +8,13 @@ class Hooks
|
|||
{
|
||||
public static function preUpdate(Event $event)
|
||||
{
|
||||
echo '!!PreUpdate:'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PreUpdate:'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
|
||||
public static function postUpdate(Event $event)
|
||||
{
|
||||
echo '!!PostUpdate:'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PostUpdate:'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ class PluginA implements PluginInterface
|
|||
{
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
echo '!!PluginAInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n";
|
||||
echo '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PluginAInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n");
|
||||
fwrite(STDERR, '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
|
|
|
@ -10,10 +10,10 @@ class PluginB implements PluginInterface
|
|||
{
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
echo '!!PluginBInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n";
|
||||
echo '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PluginBInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n");
|
||||
fwrite(STDERR, '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
|
|
|
@ -10,10 +10,10 @@ class PluginA implements PluginInterface
|
|||
{
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
echo '!!PluginAInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n";
|
||||
echo '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PluginAInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n");
|
||||
fwrite(STDERR, '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
|
|
|
@ -10,10 +10,10 @@ class PluginB implements PluginInterface
|
|||
{
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
echo '!!PluginBInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n";
|
||||
echo '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n";
|
||||
echo '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n";
|
||||
echo '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n";
|
||||
fwrite(STDERR, '!!PluginBInit'.JsonFile::encode(InstalledVersions::getInstalledPackages(), 320)."\n");
|
||||
fwrite(STDERR, '!!PluginA:'.(InstalledVersions::isInstalled('plugin/a') ? InstalledVersions::getVersion('plugin/a') : 'null')."\n");
|
||||
fwrite(STDERR, '!!PluginB:'.(InstalledVersions::isInstalled('plugin/b') ? InstalledVersions::getVersion('plugin/b') : 'null')."\n");
|
||||
fwrite(STDERR, '!!Versions:console:'.InstalledVersions::getVersion('symfony/console').';process:'.InstalledVersions::getVersion('symfony/process').';filesystem:'.InstalledVersions::getVersion('symfony/filesystem')."\n");
|
||||
}
|
||||
|
||||
public function deactivate(Composer $composer, IOInterface $io)
|
||||
|
|
Loading…
Reference in New Issue